mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-12 03:10:57 +08:00
- 调整 resources 转换成 static class 静态类;#1917
This commit is contained in:
@@ -94,9 +94,9 @@ namespace FreeSql
|
||||
{
|
||||
if (newdata == null) return null;
|
||||
var _table = Orm.CodeFirst.GetTableByEntity(EntityType);
|
||||
if (_table.Primarys.Any() == false) throw new Exception(DbContextStrings.Incomparable_EntityHasNo_PrimaryKey(Orm.GetEntityString(EntityType, newdata)));
|
||||
if (_table.Primarys.Any() == false) throw new Exception(DbContextErrorStrings.Incomparable_EntityHasNo_PrimaryKey(Orm.GetEntityString(EntityType, newdata)));
|
||||
var key = Orm.GetEntityKeyString(EntityType, newdata, false);
|
||||
if (string.IsNullOrEmpty(key)) throw new Exception(DbContextStrings.Incomparable_PrimaryKey_NotSet(Orm.GetEntityString(EntityType, newdata)));
|
||||
if (string.IsNullOrEmpty(key)) throw new Exception(DbContextErrorStrings.Incomparable_PrimaryKey_NotSet(Orm.GetEntityString(EntityType, newdata)));
|
||||
if (_states.TryGetValue(key, out var oldState) == false || oldState == null) throw new Exception($"不可对比,数据未被跟踪:{Orm.GetEntityString(EntityType, newdata)}");
|
||||
AggregateRootTrackingChangeInfo tracking = new AggregateRootTrackingChangeInfo();
|
||||
AggregateRootUtils.CompareEntityValue(_boundaryName, Orm, EntityType, oldState, newdata, null, tracking);
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace FreeSql
|
||||
var stateKey = Orm.GetEntityKeyString(EntityType, entity, false);
|
||||
if (entity == null) throw new ArgumentNullException(nameof(entity));
|
||||
var table = Orm.CodeFirst.GetTableByEntity(EntityType);
|
||||
if (table.Primarys.Any() == false) throw new Exception(DbContextStrings.CannotAdd_EntityHasNo_PrimaryKey(Orm.GetEntityString(EntityType, entity)));
|
||||
if (table.Primarys.Any() == false) throw new Exception(DbContextErrorStrings.CannotAdd_EntityHasNo_PrimaryKey(Orm.GetEntityString(EntityType, entity)));
|
||||
|
||||
var flagExists = ExistsInStates(entity);
|
||||
if (flagExists == false)
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace FreeSql
|
||||
{
|
||||
if (data == null) return;
|
||||
var table = Orm.CodeFirst.GetTableByEntity(EntityType);
|
||||
if (table.Primarys.Any() == false) throw new Exception(DbContextStrings.CannotEdit_EntityHasNo_PrimaryKey(Orm.GetEntityString(EntityType, data.First())));
|
||||
if (table.Primarys.Any() == false) throw new Exception(DbContextErrorStrings.CannotEdit_EntityHasNo_PrimaryKey(Orm.GetEntityString(EntityType, data.First())));
|
||||
_statesEditing.Clear();
|
||||
_dataEditing = data;
|
||||
foreach (var item in data)
|
||||
@@ -216,7 +216,7 @@ namespace FreeSql
|
||||
var stateKey = Orm.GetEntityKeyString(EntityType, entity, false);
|
||||
if (entity == null) throw new ArgumentNullException(nameof(entity));
|
||||
var table = Orm.CodeFirst.GetTableByEntity(EntityType);
|
||||
if (table.Primarys.Any() == false) throw new Exception(DbContextStrings.CannotAdd_EntityHasNo_PrimaryKey(Orm.GetEntityString(EntityType, entity)));
|
||||
if (table.Primarys.Any() == false) throw new Exception(DbContextErrorStrings.CannotAdd_EntityHasNo_PrimaryKey(Orm.GetEntityString(EntityType, entity)));
|
||||
|
||||
var flagExists = ExistsInStates(entity);
|
||||
if (flagExists == false)
|
||||
|
||||
@@ -499,7 +499,7 @@ namespace FreeSql
|
||||
void LocalInclude(TableRef tbref, Expression exp)
|
||||
{
|
||||
var incMethod = queryExp.Type.GetMethod("Include");
|
||||
if (incMethod == null) throw new Exception(CoreStrings.RunTimeError_Reflection_IncludeMany.Replace("IncludeMany", "Include"));
|
||||
if (incMethod == null) throw new Exception(CoreErrorStrings.RunTimeError_Reflection_IncludeMany.Replace("IncludeMany", "Include"));
|
||||
queryExp = Expression.Call(queryExp, incMethod.MakeGenericMethod(tbref.RefEntityType),
|
||||
Expression.Lambda(typeof(Func<,>).MakeGenericType(entityType, tbref.RefEntityType), exp, navigateParameterExp));
|
||||
}
|
||||
@@ -508,7 +508,7 @@ namespace FreeSql
|
||||
var funcType = typeof(Func<,>).MakeGenericType(entityType, typeof(IEnumerable<>).MakeGenericType(tbref.RefEntityType));
|
||||
var navigateSelector = Expression.Lambda(funcType, exp, navigateParameterExp);
|
||||
var incMethod = queryExp.Type.GetMethod("IncludeMany");
|
||||
if (incMethod == null) throw new Exception(CoreStrings.RunTimeError_Reflection_IncludeMany);
|
||||
if (incMethod == null) throw new Exception(CoreErrorStrings.RunTimeError_Reflection_IncludeMany);
|
||||
LambdaExpression navigateThen = null;
|
||||
var navigateThenType = typeof(Action<>).MakeGenericType(typeof(ISelect<>).MakeGenericType(tbref.RefEntityType));
|
||||
var thenParameter = Expression.Parameter(typeof(ISelect<>).MakeGenericType(tbref.RefEntityType), "then");
|
||||
|
||||
Reference in New Issue
Block a user