diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMany.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMany.cs index 2c9321d15..7d951c0e0 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMany.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMany.cs @@ -12,13 +12,39 @@ namespace OrmTest { var db = NewUnitTest.Db; db.CodeFirst.InitTables(); + db.DbMaintenance.TruncateTable(); + db.Insertable(new OperatorInfo() + { + id="1", + createTime=DateTime.Now, + isDel=1, + isDisabled=1, + openid="", + phone="", + pwd="", + realname="a01", + remark="a", + sno="a", + username="a01" + }).ExecuteCommand(); + var id=db.Insertable(new Role() + { + id=1, + createTime=DateTime.Now, + name="admin" + + }).ExecuteReturnIdentity(); + db.Insertable(new OptRole() { operId="1", roleId=id }).ExecuteCommand(); db.Queryable() .Includes(x => x.Roles).Where(x => x.Roles.Any(z=>z.id==1)) .ToList(); db.Queryable() - .Includes(x => x.Roles).Where(x => x.Roles.Any()) - .ToList(); - } + .Includes(x => x.Roles).Where(x => x.Roles.Any()) + .ToList(); + //db.Queryable() + // .Includes(x => x.Roles.Where(z=>z.name==x.realname).ToList()) + // .ToList(); + } /// /// 描述: diff --git a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs index 118c7283f..d4f402f83 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs @@ -255,6 +255,14 @@ namespace SqlSugar object setValue = 0; if (idValue > int.MaxValue) setValue = idValue; + else if (this.EntityInfo.Columns.Any(it => it.IsIdentity && it.PropertyInfo.PropertyType == typeof(uint))) + { + setValue = Convert.ToUInt32(idValue); + } + else if (this.EntityInfo.Columns.Any(it => it.IsIdentity && it.PropertyInfo.PropertyType == typeof(ulong))) + { + setValue = Convert.ToUInt64(idValue); + } else setValue = Convert.ToInt32(idValue); this.Context.EntityMaintenance.GetProperty(identityKey).SetValue(result, setValue, null);