diff --git a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj index a732b5554..ed6c66add 100644 --- a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj +++ b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj @@ -94,6 +94,7 @@ + diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs b/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs index 2cded3d6e..56f7a1881 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs @@ -31,6 +31,7 @@ namespace OrmTest } public static void Init() { + UnitManyToMany.Init(); UCustom018.Init(); UCustom017.Init(); UCustom016.Init(); diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMany.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMany.cs new file mode 100644 index 000000000..0804ef28f --- /dev/null +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMany.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SqlSugar; +namespace OrmTest +{ + internal class UnitManyToMany + { + public static void Init() + { + var db = NewUnitTest.Db; + db.CodeFirst.InitTables(); + db.Queryable() + .Includes(x => x.Roles).Where(x => x.Roles.Any()) + .ToList(); + } + + /// + /// 描述: + /// 作者:synjones + /// 时间:2022-04-20 21:30:28 + /// + [SugarTable("unit_operatorinfo")] + public partial class OperatorInfo + { /// + /// 多角色 + /// + [Navigate(typeof(OptRole), nameof(OptRole.operId), nameof(OptRole.roleId))]//名字换 + public List Roles { get; set; } + /// + /// 主键 + /// + [SugarColumn(IsPrimaryKey = true)] + public string id { get; set; } + + /// + /// 姓名 + /// + public string realname { get; set; } + + /// + /// 账号 + /// + public string username { get; set; } + + /// + /// 密码 + /// + public string pwd { get; set; } + + /// + /// 学号 + /// + public string sno { get; set; } + + /// + /// openid + /// + public string openid { get; set; } + + /// + /// 手机号码 + /// + public string phone { get; set; } + + /// + /// 备注信息 + /// + public string remark { get; set; } + + /// + /// 创建日期 + /// + public DateTime createTime { get; set; } + + /// + /// 状态(1:启用,2:禁用) + /// + public int isDisabled { get; set; } + + /// + /// 是否删除(1:正常;2:删除) + /// + public int isDel { get; set; } + + } + + /// + /// 描述: + /// 作者:synjones + /// 时间:2022-04-20 21:30:28 + /// + [SugarTable("unit_role1")] + public partial class Role + { + /// + /// 角色 + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int id { get; set; } + + /// + /// 角色名称 + /// + public string name { get; set; } + + /// + /// 创建时间 + /// + public DateTime createTime { get; set; } + + + } + + /// + /// 描述: + /// 作者:synjones + /// 时间:2022-04-21 14:35:09 + /// + [SugarTable("unit_operator_role")] + public partial class OptRole + { + /// + /// + /// + [SugarColumn(IsPrimaryKey = true)] + public int id { get; set; } + + /// + /// + /// + public string operId { get; set; } + + /// + /// + /// + public int roleId { get; set; } + + + } + } +}