This commit is contained in:
sunkaixuan 2022-04-14 12:53:53 +08:00
parent 6acffac179
commit 73a6804a54
16 changed files with 48 additions and 48 deletions

View File

@ -149,9 +149,9 @@ namespace OrmTest
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public int ParentId { get; set; } public int ParentId { get; set; }
[Navigat(NavigatType.OneToOne,nameof(ParentId))] [Navigate(NavigateType.OneToOne,nameof(ParentId))]
public Tree1 Parent { get; set; } public Tree1 Parent { get; set; }
[Navigat(NavigatType.OneToMany,nameof(Tree1.ParentId))] [Navigate(NavigateType.OneToMany,nameof(Tree1.ParentId))]
public List<Tree1> Child { get; set; } public List<Tree1> Child { get; set; }
} }
public class ABMapping1 public class ABMapping1
@ -166,7 +166,7 @@ namespace OrmTest
[SugarColumn(IsPrimaryKey = true )] [SugarColumn(IsPrimaryKey = true )]
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
[Navigat(typeof(ABMapping1),nameof(ABMapping1.AId),nameof(ABMapping1.BId))] [Navigate(typeof(ABMapping1),nameof(ABMapping1.AId),nameof(ABMapping1.BId))]
public List<B1> BList { get; set; } public List<B1> BList { get; set; }
} }
public class B1 public class B1
@ -174,7 +174,7 @@ namespace OrmTest
[SugarColumn(IsPrimaryKey = true )] [SugarColumn(IsPrimaryKey = true )]
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
[Navigat(typeof(ABMapping1), nameof(ABMapping1.BId), nameof(ABMapping1.AId))] [Navigate(typeof(ABMapping1), nameof(ABMapping1.BId), nameof(ABMapping1.AId))]
public List<A1> AList { get; set; } public List<A1> AList { get; set; }
} }
@ -184,9 +184,9 @@ namespace OrmTest
public int StudentId { get; set; } public int StudentId { get; set; }
public string Name { get; set; } public string Name { get; set; }
public int SchoolId { get; set; } public int SchoolId { get; set; }
[Navigat(NavigatType.OneToOne, nameof(SchoolId))] [Navigate(NavigateType.OneToOne, nameof(SchoolId))]
public SchoolA SchoolA { get; set; } public SchoolA SchoolA { get; set; }
[Navigat(NavigatType.OneToMany, nameof(BookA.studenId))] [Navigate(NavigateType.OneToMany, nameof(BookA.studenId))]
public List<BookA> Books { get; set; } public List<BookA> Books { get; set; }
} }
@ -195,7 +195,7 @@ namespace OrmTest
[SugarColumn(IsPrimaryKey = true)] [SugarColumn(IsPrimaryKey = true)]
public int SchoolId { get; set; } public int SchoolId { get; set; }
public string SchoolName { get; set; } public string SchoolName { get; set; }
[Navigat(NavigatType.OneToMany,nameof(RoomA.SchoolId))] [Navigate(NavigateType.OneToMany,nameof(RoomA.SchoolId))]
public List<RoomA> RoomList { get; set; } public List<RoomA> RoomList { get; set; }
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
public List<TeacherA> TeacherList { get; set; } public List<TeacherA> TeacherList { get; set; }

View File

@ -104,7 +104,7 @@ namespace OrmTest
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
[Navigat(NavigatType.OneToMany,nameof(Province111.CountryId))] [Navigate(NavigateType.OneToMany,nameof(Province111.CountryId))]
public List<Province111> Provinces { get; set; } public List<Province111> Provinces { get; set; }
} }
[SugarTable("Province_111")] [SugarTable("Province_111")]
@ -115,7 +115,7 @@ namespace OrmTest
public string Name { get; set; } public string Name { get; set; }
[SugarColumn(ColumnName = "coid")] [SugarColumn(ColumnName = "coid")]
public int CountryId { get; set; } public int CountryId { get; set; }
[Navigat(NavigatType.OneToMany, nameof(City111.ProvinceId))] [Navigate(NavigateType.OneToMany, nameof(City111.ProvinceId))]
public List<City111> citys { get; set; } public List<City111> citys { get; set; }
} }
[SugarTable("City_111")] [SugarTable("City_111")]

View File

@ -68,10 +68,10 @@ namespace OrmTest
public string Name { get; set; } public string Name { get; set; }
public int InfoId { get; set; } public int InfoId { get; set; }
[Navigat(NavigatType.OneToOne, nameof(InfoId))] [Navigate(NavigateType.OneToOne, nameof(InfoId))]
public Country111Info Info { get; set; } public Country111Info Info { get; set; }
[Navigat(NavigatType.OneToMany,nameof(Province1111.CountryId))] [Navigate(NavigateType.OneToMany,nameof(Province1111.CountryId))]
public List<Province1111> Provinces { get; set; } public List<Province1111> Provinces { get; set; }
} }

View File

@ -149,9 +149,9 @@ namespace OrmTest
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public int ParentId { get; set; } public int ParentId { get; set; }
[Navigat(NavigatType.OneToOne,nameof(ParentId))] [Navigate(NavigateType.OneToOne,nameof(ParentId))]
public Tree1 Parent { get; set; } public Tree1 Parent { get; set; }
[Navigat(NavigatType.OneToMany,nameof(Tree1.ParentId))] [Navigate(NavigateType.OneToMany,nameof(Tree1.ParentId))]
public List<Tree1> Child { get; set; } public List<Tree1> Child { get; set; }
} }
public class ABMapping1 public class ABMapping1
@ -166,7 +166,7 @@ namespace OrmTest
[SugarColumn(IsPrimaryKey = true )] [SugarColumn(IsPrimaryKey = true )]
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
[Navigat(typeof(ABMapping1),nameof(ABMapping1.AId),nameof(ABMapping1.BId))] [Navigate(typeof(ABMapping1),nameof(ABMapping1.AId),nameof(ABMapping1.BId))]
public List<B1> BList { get; set; } public List<B1> BList { get; set; }
} }
public class B1 public class B1
@ -174,7 +174,7 @@ namespace OrmTest
[SugarColumn(IsPrimaryKey = true )] [SugarColumn(IsPrimaryKey = true )]
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
[Navigat(typeof(ABMapping1), nameof(ABMapping1.BId), nameof(ABMapping1.AId))] [Navigate(typeof(ABMapping1), nameof(ABMapping1.BId), nameof(ABMapping1.AId))]
public List<A1> AList { get; set; } public List<A1> AList { get; set; }
} }
@ -184,9 +184,9 @@ namespace OrmTest
public int StudentId { get; set; } public int StudentId { get; set; }
public string Name { get; set; } public string Name { get; set; }
public int SchoolId { get; set; } public int SchoolId { get; set; }
[Navigat(NavigatType.OneToOne, nameof(SchoolId))] [Navigate(NavigateType.OneToOne, nameof(SchoolId))]
public SchoolA SchoolA { get; set; } public SchoolA SchoolA { get; set; }
[Navigat(NavigatType.OneToMany, nameof(BookA.studenId))] [Navigate(NavigateType.OneToMany, nameof(BookA.studenId))]
public List<BookA> Books { get; set; } public List<BookA> Books { get; set; }
} }
@ -195,7 +195,7 @@ namespace OrmTest
[SugarColumn(IsPrimaryKey = true)] [SugarColumn(IsPrimaryKey = true)]
public int SchoolId { get; set; } public int SchoolId { get; set; }
public string SchoolName { get; set; } public string SchoolName { get; set; }
[Navigat(NavigatType.OneToMany,nameof(RoomA.SchoolId))] [Navigate(NavigateType.OneToMany,nameof(RoomA.SchoolId))]
public List<RoomA> RoomList { get; set; } public List<RoomA> RoomList { get; set; }
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
public List<TeacherA> TeacherList { get; set; } public List<TeacherA> TeacherList { get; set; }

View File

@ -104,7 +104,7 @@ namespace OrmTest
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
[Navigat(NavigatType.OneToMany,nameof(Province111.CountryId))] [Navigate(NavigateType.OneToMany,nameof(Province111.CountryId))]
public List<Province111> Provinces { get; set; } public List<Province111> Provinces { get; set; }
} }
[SugarTable("Province_111")] [SugarTable("Province_111")]
@ -115,7 +115,7 @@ namespace OrmTest
public string Name { get; set; } public string Name { get; set; }
[SugarColumn(ColumnName = "coid")] [SugarColumn(ColumnName = "coid")]
public int CountryId { get; set; } public int CountryId { get; set; }
[Navigat(NavigatType.OneToMany, nameof(City111.ProvinceId))] [Navigate(NavigateType.OneToMany, nameof(City111.ProvinceId))]
public List<City111> citys { get; set; } public List<City111> citys { get; set; }
} }
[SugarTable("City_111")] [SugarTable("City_111")]

View File

@ -68,10 +68,10 @@ namespace OrmTest
public string Name { get; set; } public string Name { get; set; }
public int InfoId { get; set; } public int InfoId { get; set; }
[Navigat(NavigatType.OneToOne, nameof(InfoId))] [Navigate(NavigateType.OneToOne, nameof(InfoId))]
public Country111Info Info { get; set; } public Country111Info Info { get; set; }
[Navigat(NavigatType.OneToMany,nameof(Province1111.CountryId))] [Navigate(NavigateType.OneToMany,nameof(Province1111.CountryId))]
public List<Province1111> Provinces { get; set; } public List<Province1111> Provinces { get; set; }
} }

View File

@ -149,9 +149,9 @@ namespace OrmTest
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public int ParentId { get; set; } public int ParentId { get; set; }
[Navigat(NavigatType.OneToOne,nameof(ParentId))] [Navigate(NavigateType.OneToOne,nameof(ParentId))]
public Tree1 Parent { get; set; } public Tree1 Parent { get; set; }
[Navigat(NavigatType.OneToMany,nameof(Tree1.ParentId))] [Navigate(NavigateType.OneToMany,nameof(Tree1.ParentId))]
public List<Tree1> Child { get; set; } public List<Tree1> Child { get; set; }
} }
public class ABMapping1 public class ABMapping1
@ -166,7 +166,7 @@ namespace OrmTest
[SugarColumn(IsPrimaryKey = true )] [SugarColumn(IsPrimaryKey = true )]
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
[Navigat(typeof(ABMapping1),nameof(ABMapping1.AId),nameof(ABMapping1.BId))] [Navigate(typeof(ABMapping1),nameof(ABMapping1.AId),nameof(ABMapping1.BId))]
public List<B1> BList { get; set; } public List<B1> BList { get; set; }
} }
public class B1 public class B1
@ -174,7 +174,7 @@ namespace OrmTest
[SugarColumn(IsPrimaryKey = true )] [SugarColumn(IsPrimaryKey = true )]
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
[Navigat(typeof(ABMapping1), nameof(ABMapping1.BId), nameof(ABMapping1.AId))] [Navigate(typeof(ABMapping1), nameof(ABMapping1.BId), nameof(ABMapping1.AId))]
public List<A1> AList { get; set; } public List<A1> AList { get; set; }
} }
@ -184,9 +184,9 @@ namespace OrmTest
public int StudentId { get; set; } public int StudentId { get; set; }
public string Name { get; set; } public string Name { get; set; }
public int SchoolId { get; set; } public int SchoolId { get; set; }
[Navigat(NavigatType.OneToOne, nameof(SchoolId))] [Navigate(NavigateType.OneToOne, nameof(SchoolId))]
public SchoolA SchoolA { get; set; } public SchoolA SchoolA { get; set; }
[Navigat(NavigatType.OneToMany, nameof(BookA.studenId))] [Navigate(NavigateType.OneToMany, nameof(BookA.studenId))]
public List<BookA> Books { get; set; } public List<BookA> Books { get; set; }
} }
@ -195,7 +195,7 @@ namespace OrmTest
[SugarColumn(IsPrimaryKey = true)] [SugarColumn(IsPrimaryKey = true)]
public int SchoolId { get; set; } public int SchoolId { get; set; }
public string SchoolName { get; set; } public string SchoolName { get; set; }
[Navigat(NavigatType.OneToMany,nameof(RoomA.SchoolId))] [Navigate(NavigateType.OneToMany,nameof(RoomA.SchoolId))]
public List<RoomA> RoomList { get; set; } public List<RoomA> RoomList { get; set; }
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
public List<TeacherA> TeacherList { get; set; } public List<TeacherA> TeacherList { get; set; }

View File

@ -109,7 +109,7 @@ namespace OrmTest
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
[Navigat(NavigatType.OneToMany,nameof(Province111.CountryId))] [Navigate(NavigateType.OneToMany,nameof(Province111.CountryId))]
public List<Province111> Provinces { get; set; } public List<Province111> Provinces { get; set; }
} }
[SugarTable("Province_111")] [SugarTable("Province_111")]
@ -120,7 +120,7 @@ namespace OrmTest
public string Name { get; set; } public string Name { get; set; }
[SugarColumn(ColumnName = "coid")] [SugarColumn(ColumnName = "coid")]
public int CountryId { get; set; } public int CountryId { get; set; }
[Navigat(NavigatType.OneToMany, nameof(City111.ProvinceId))] [Navigate(NavigateType.OneToMany, nameof(City111.ProvinceId))]
public List<City111> citys { get; set; } public List<City111> citys { get; set; }
} }
[SugarTable("City_111")] [SugarTable("City_111")]

View File

@ -73,10 +73,10 @@ namespace OrmTest
public string Name { get; set; } public string Name { get; set; }
public int InfoId { get; set; } public int InfoId { get; set; }
[Navigat(NavigatType.OneToOne, nameof(InfoId))] [Navigate(NavigateType.OneToOne, nameof(InfoId))]
public Country111Info Info { get; set; } public Country111Info Info { get; set; }
[Navigat(NavigatType.OneToMany,nameof(Province1111.CountryId))] [Navigate(NavigateType.OneToMany,nameof(Province1111.CountryId))]
public List<Province1111> Provinces { get; set; } public List<Province1111> Provinces { get; set; }
} }

View File

@ -220,11 +220,11 @@ namespace SqlSugar
EntityColumnInfo column = new EntityColumnInfo(); EntityColumnInfo column = new EntityColumnInfo();
//var isVirtual = property.GetGetMethod().IsVirtual; //var isVirtual = property.GetGetMethod().IsVirtual;
//if (isVirtual) continue; //if (isVirtual) continue;
var navigat=property.GetCustomAttribute(typeof(Navigat)); var navigat=property.GetCustomAttribute(typeof(Navigate));
if (navigat != null) if (navigat != null)
{ {
column.IsIgnore = true; column.IsIgnore = true;
column.Navigat = navigat as Navigat; column.Navigat = navigat as Navigate;
} }
var sugarColumn = property.GetCustomAttributes(typeof(SugarColumn), true) var sugarColumn = property.GetCustomAttributes(typeof(SugarColumn), true)
.Where(it => it is SugarColumn) .Where(it => it is SugarColumn)

View File

@ -114,15 +114,15 @@ namespace SqlSugar
if (navObjectNameColumnInfo.Navigat.NavigatType == NavigatType.OneToOne) if (navObjectNameColumnInfo.Navigat.NavigatType == NavigateType.OneToOne)
{ {
OneToOne(list, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo); OneToOne(list, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo);
} }
else if (navObjectNameColumnInfo.Navigat.NavigatType == NavigatType.OneToMany) else if (navObjectNameColumnInfo.Navigat.NavigatType == NavigateType.OneToMany)
{ {
OneToMany(list, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo); OneToMany(list, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo);
} }
else if (navObjectNameColumnInfo.Navigat.NavigatType == NavigatType.ManyToOne) else if (navObjectNameColumnInfo.Navigat.NavigatType == NavigateType.ManyToOne)
{ {
OneToOne(list, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo); OneToOne(list, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo);
} }

View File

@ -36,6 +36,6 @@ namespace SqlSugar
public string[] UIndexGroupNameList { get; set; } public string[] UIndexGroupNameList { get; set; }
public bool IsArray { get; set; } public bool IsArray { get; set; }
public Type UnderType { get; set; } public Type UnderType { get; set; }
public Navigat Navigat { get; set; } public Navigate Navigat { get; set; }
} }
} }

View File

@ -204,24 +204,24 @@ namespace SqlSugar
} }
[AttributeUsage(AttributeTargets.Property, Inherited = true)] [AttributeUsage(AttributeTargets.Property, Inherited = true)]
public class Navigat: Attribute public class Navigate: Attribute
{ {
public string Name { get; set; } public string Name { get; set; }
public Type MappingType { get; set; } public Type MappingType { get; set; }
public string MappingAId { get; set; } public string MappingAId { get; set; }
public string MappingBId { get; set; } public string MappingBId { get; set; }
public NavigatType NavigatType { get; set; } public NavigateType NavigatType { get; set; }
public Navigat(NavigatType navigatType,string name) public Navigate(NavigateType navigatType,string name)
{ {
this.Name = name; this.Name = name;
this.NavigatType = navigatType; this.NavigatType = navigatType;
} }
public Navigat(Type MappingTableType,string typeAiD,string typeBId) public Navigate(Type MappingTableType,string typeAiD,string typeBId)
{ {
this.MappingType = MappingTableType; this.MappingType = MappingTableType;
this.MappingAId = typeAiD; this.MappingAId = typeAiD;
this.MappingBId = typeBId; this.MappingBId = typeBId;
this.NavigatType = NavigatType.ManyToMany; this.NavigatType = NavigateType.ManyToMany;
} }
} }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace SqlSugar namespace SqlSugar
{ {
public enum NavigatType public enum NavigateType
{ {
OneToOne=1, OneToOne=1,
OneToMany=2, OneToMany=2,

View File

@ -12,7 +12,7 @@ namespace SqlSugar
private SqlSugarProvider context; private SqlSugarProvider context;
private EntityInfo EntityInfo; private EntityInfo EntityInfo;
private EntityInfo ProPertyEntity; private EntityInfo ProPertyEntity;
private Navigat Navigat; private Navigate Navigat;
public string ShorName; public string ShorName;
private string MemberName; private string MemberName;
public OneToOneNavgateExpression(SqlSugarProvider context) public OneToOneNavgateExpression(SqlSugarProvider context)

View File

@ -12,7 +12,7 @@ namespace SqlSugar
private SqlSugarProvider context; private SqlSugarProvider context;
private EntityInfo EntityInfo; private EntityInfo EntityInfo;
private EntityInfo ProPertyEntity; private EntityInfo ProPertyEntity;
private Navigat Navigat; private Navigate Navigat;
public string ShorName; public string ShorName;
private string MemberName; private string MemberName;
private string MethodName; private string MethodName;
@ -82,7 +82,7 @@ namespace SqlSugar
} }
internal MapperSql GetSql() internal MapperSql GetSql()
{ {
if (Navigat.NavigatType == NavigatType.OneToMany) if (Navigat.NavigatType == NavigateType.OneToMany)
{ {
return GetOneToManySql(); return GetOneToManySql();
} }