private List <ClrTypeEdmSet> GetClrTypeEdmSetList(IEdmModel edmModel, OeEntitySetAdapterCollection entitySetAdapters) { var clrTypeEdmSetList = new List <ClrTypeEdmSet>(); foreach (Type entityType in _tables.Keys) { OeEntitySetAdapter entitSetAdapter = entitySetAdapters.FindByClrType(entityType); IEdmEntitySet entitySet = edmModel.FindDeclaredEntitySet(entitSetAdapter.EntitySetName); clrTypeEdmSetList.Add(new ClrTypeEdmSet(entityType, entitySet)); } var orderedTypes = new List <ClrTypeEdmSet>(); while (clrTypeEdmSetList.Count > 0) { for (int i = 0; i < clrTypeEdmSetList.Count; i++) { if (IsDependent(clrTypeEdmSetList[i], clrTypeEdmSetList, out PropertyInfo selfRefProperty)) { if (selfRefProperty != null) { _tables[selfRefProperty.DeclaringType].SelfRefProperty = selfRefProperty; } orderedTypes.Add(clrTypeEdmSetList[i]); clrTypeEdmSetList.RemoveAt(i); break; } } } return(orderedTypes); }
private static ClrTableTypeEdmSet[] GetOrderedTableTypes(IEdmModel edmModel, OeEntitySetAdapterCollection entitySetAdapters) { var clrTypeEdmSetList = new List <ClrTableTypeEdmSet>(); foreach (OeEntitySetAdapter entitySetAdapter in entitySetAdapters) { IEdmEntitySet entitySet = OeEdmClrHelper.GetEntitySet(edmModel, entitySetAdapter.EntitySetName); clrTypeEdmSetList.Add(new ClrTableTypeEdmSet(entitySetAdapter.EntityType, entitySet)); } var orderedTableTypeList = new List <ClrTableTypeEdmSet>(); while (clrTypeEdmSetList.Count > 0) { for (int i = 0; i < clrTypeEdmSetList.Count; i++) { if (IsDependent(clrTypeEdmSetList[i], clrTypeEdmSetList, out PropertyInfo selfRefProperty)) { Type linq2DbTableType = typeof(OeLinq2DbTable <>).MakeGenericType(clrTypeEdmSetList[i].ClrTableType); if (selfRefProperty != null) { linq2DbTableType.GetProperty(nameof(OeLinq2DbTable <Object> .SelfRefProperty)).SetValue(null, selfRefProperty); } orderedTableTypeList.Add(clrTypeEdmSetList[i]); clrTypeEdmSetList.RemoveAt(i); break; } } } return(orderedTableTypeList.ToArray()); }
public OeLinq2DbDataContext(IEdmModel edmModel, OeEntitySetAdapterCollection entitySetAdapters) { if (_orderedTableTypes == null) { _orderedTableTypes = GetOrderedTableTypes(edmModel, entitySetAdapters); } _tables = new Dictionary <Type, OeLinq2DbTable>(_orderedTableTypes.Length); }
public OeLinq2DbDataContext(IEdmModel edmModel, OeEntitySetAdapterCollection entitySetAdapters) { if (!_edmModelOrderedTableTypes.TryGetValue(edmModel, out _orderedTableTypes)) { _orderedTableTypes = GetOrderedTableTypes(edmModel, entitySetAdapters); _edmModelOrderedTableTypes.TryAdd(edmModel, _orderedTableTypes); } _tables = new Dictionary <Type, OeLinq2DbTable>(_orderedTableTypes.Length); }
public int SaveChanges(IEdmModel edmModel, OeEntitySetAdapterCollection entitySetAdapters, DataConnection dataConnection) { List <ClrTypeEdmSet> clrTypeEdmSetList = GetClrTypeEdmSetList(edmModel, entitySetAdapters); int count = 0; for (int i = clrTypeEdmSetList.Count - 1; i >= 0; i--) { OeLinq2DbTable table = GetTable(clrTypeEdmSetList[i].ClrType); count += table.SaveInserted(dataConnection); UpdateIdentities(table, clrTypeEdmSetList, i); count += table.SaveUpdated(dataConnection); } for (int i = 0; i < clrTypeEdmSetList.Count; i++) { OeLinq2DbTable table = GetTable(clrTypeEdmSetList[i].ClrType); count += table.SaveDeleted(dataConnection); } return(count); }
public OeEfCorePostgreSqlOperationAdapter(Type dataContextType, OeEntitySetAdapterCollection entitySetAdapters) : base(dataContextType, entitySetAdapters) { }
public OeLinq2DbDataContext(IEdmModel edmModel, OeEntitySetAdapterCollection entitySetAdapters) { if (_edmModelOrderedTableTypes.TryGetValue(edmModel, out ClrTableTypeEdmSet[]? orderedTableTypes))
public OeEfCoreOperationAdapter(Type dataContextType, OeEntitySetAdapterCollection entitySetAdapters) : base(dataContextType) { _entitySetAdapters = entitySetAdapters; }