2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-26 21:13:13 +00:00
This commit is contained in:
2022-03-09 21:55:30 +03:00
parent 530df018ec
commit 9a174f406f
106 changed files with 5166 additions and 4398 deletions

View File

@ -39,6 +39,11 @@ public class EntityStore : IStore
{
public Instance Instance { get; set; }
bool initialized = false;
public bool Initialized => initialized;
public event DestroyedEvent OnDestroy;
Dictionary<Type, Dictionary<object, WeakReference>> DB = new Dictionary<Type, Dictionary<object, WeakReference>>();
@ -92,6 +97,9 @@ public class EntityStore : IStore
public IResource GetById(Type type, object id)
{
if (!initialized)
throw new Exception("Store not initalized. Make sure the Warehouse is open.");
lock (DBLock)
{
if (!DB[type].ContainsKey(id))
@ -136,13 +144,13 @@ public class EntityStore : IStore
return this.Instance.Name + "/" + type.Name;
}
public bool Record(IResource resource, string propertyName, object value, ulong age, DateTime dateTime)
public bool Record(IResource resource, string propertyName, object value, ulong? age, DateTime? dateTime)
{
return true;
//throw new NotImplementedException();
}
public bool Modify(IResource resource, string propertyName, object value, ulong age, DateTime dateTime)
public bool Modify(IResource resource, string propertyName, object value, ulong? age, DateTime? dateTime)
{
return true;
//throw new NotImplementedException();
@ -201,6 +209,8 @@ public class EntityStore : IStore
ReloadModel();
initialized = true;
}
return new AsyncReply<bool>(true);

View File

@ -9,7 +9,7 @@
<Product>Esiur Entity Framework Extension</Product>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Esiur.Stores.EntityCore</PackageId>
<Version>1.2.5</Version>
<Version>1.2.9</Version>
<LangVersion>latest</LangVersion>
</PropertyGroup>
@ -22,7 +22,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
<PackageReference Include="System.Collections" Version="4.3.0" />
</ItemGroup>

View File

@ -54,6 +54,8 @@ public static class EsiurExtensions
{
var store = dbSet.GetInfrastructure().GetService<IDbContextOptions>().FindExtension<EsiurExtensionOptions>().Store;
if (!store.Initialized)
throw new Exception("Store not initialized. Make sure the Warehouse is open");
var manager = store.Instance.Managers.FirstOrDefault();// > 0 ? store.Instance.Managers.First() : null;
@ -75,7 +77,7 @@ public static class EsiurExtensions
else
{
res = Activator.CreateInstance(proxyType) as IResource;
var ps = Structure.FromObject(resource);
var ps = Map<string,object>.FromObject(resource);
foreach (var p in ps)
{