2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 05:23:13 +00:00
This commit is contained in:
2020-06-18 02:27:48 +03:00
parent cca00ca97e
commit 8c2d616d62
18 changed files with 379 additions and 164 deletions

View File

@ -37,7 +37,7 @@ namespace Esyur.Stores.EntityCore
public class EntityResource : IResource
{
[NotMapped]
internal int _PrimaryId;
internal object _PrimaryId;
public event DestroyedEvent OnDestroy;
public event PropertyChangedEventHandler PropertyChanged;

View File

@ -45,7 +45,7 @@ namespace Esyur.Stores.EntityCore
public event DestroyedEvent OnDestroy;
Dictionary<Type, Dictionary<int, WeakReference>> DB = new Dictionary<Type, Dictionary<int, WeakReference>>();
Dictionary<Type, Dictionary<object, WeakReference>> DB = new Dictionary<Type, Dictionary<object, WeakReference>>();
internal struct TypeInfo
{
@ -203,7 +203,7 @@ namespace Esyur.Stores.EntityCore
TypesByName.Add(t.ClrType.Name, ti);
TypesByType.Add(t.ClrType, ti);
DB.Add(t.ClrType, new Dictionary<int, WeakReference>());
DB.Add(t.ClrType, new Dictionary<object, WeakReference>());
}
}

View File

@ -35,15 +35,19 @@ namespace Esyur.Stores.EntityCore
{
public static class EsyurExtensions
{
public static T CreateResource<T>(this DbContext dbContext, object properties = null) where T:class,IResource
{
return dbContext.GetInfrastructure().CreateResource<T>(properties);
//public static T CreateResource<T>(this DbContext dbContext, object properties = null) where T:class,IResource
//{
// return dbContext.GetInfrastructure().CreateResource<T>(properties);
}
//}
public static T CreateResource<T>(this DbSet<T> dbSet, object properties = null) where T:class,IResource
public static T AddResource<T>(this DbSet<T> dbSet, object properties = null) where T:class,IResource
{
var resource = dbSet.GetInfrastructure().CreateResource<T>(properties);
var store = dbSet.GetInfrastructure().GetService<IDbContextOptions>().FindExtension<EsyurExtensionOptions>().Store;
//var resource = dbSet.GetInfrastructure().CreateResource<T>(properties);
//var resource = Warehouse.New<T>("", options.Store, null, null, null, properties);
var resource = Warehouse.New<T>("", null, null, null, null, properties);
dbSet.Add(resource);
return resource;
}