mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-06-27 05:23:13 +00:00
Token
This commit is contained in:
@ -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;
|
||||
|
@ -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>());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user