mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-14 20:30:56 +08:00
- 调整 resources 转换成 static class 静态类;#1917
This commit is contained in:
@@ -197,12 +197,12 @@ namespace FreeSql
|
||||
TEntity CheckTKeyAndReturnIdEntity(TKey id)
|
||||
{
|
||||
var tb = _db.OrmOriginal.CodeFirst.GetTableByEntity(EntityType);
|
||||
if (tb.Primarys.Length != 1) throw new Exception(DbContextStrings.EntityType_PrimaryKeyIsNotOne(EntityType.Name));
|
||||
if (tb.Primarys[0].CsType.NullableTypeOrThis() != typeof(TKey).NullableTypeOrThis()) throw new Exception(DbContextStrings.EntityType_PrimaryKeyError(EntityType.Name, typeof(TKey).FullName));
|
||||
if (tb.Primarys.Length != 1) throw new Exception(DbContextErrorStrings.EntityType_PrimaryKeyIsNotOne(EntityType.Name));
|
||||
if (tb.Primarys[0].CsType.NullableTypeOrThis() != typeof(TKey).NullableTypeOrThis()) throw new Exception(DbContextErrorStrings.EntityType_PrimaryKeyError(EntityType.Name, typeof(TKey).FullName));
|
||||
var obj = tb.Type.CreateInstanceGetDefaultValue();
|
||||
_db.OrmOriginal.SetEntityValueWithPropertyName(tb.Type, obj, tb.Primarys[0].CsName, id);
|
||||
var ret = obj as TEntity;
|
||||
if (ret == null) throw new Exception(DbContextStrings.EntityType_CannotConvert(EntityType.Name, typeof(TEntity).Name));
|
||||
if (ret == null) throw new Exception(DbContextErrorStrings.EntityType_CannotConvert(EntityType.Name, typeof(TEntity).Name));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user