mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 11:32:59 +00:00
Generic Record/Resource
This commit is contained in:
parent
499f1e37d2
commit
fbae3eb960
@ -54,6 +54,9 @@ public static class EsiurExtensions
|
|||||||
{
|
{
|
||||||
var store = dbSet.GetInfrastructure().GetService<IDbContextOptions>().FindExtension<EsiurExtensionOptions>().Store;
|
var store = dbSet.GetInfrastructure().GetService<IDbContextOptions>().FindExtension<EsiurExtensionOptions>().Store;
|
||||||
|
|
||||||
|
if (store == null)
|
||||||
|
throw new Exception("Store not set, please call 'UseEsiur' on your DbContextOptionsBuilder.");
|
||||||
|
|
||||||
if (!store.Initialized)
|
if (!store.Initialized)
|
||||||
throw new Exception("Store not initialized. Make sure the Warehouse is open");
|
throw new Exception("Store not initialized. Make sure the Warehouse is open");
|
||||||
|
|
||||||
|
19
Test/MyGenericRecord.cs
Normal file
19
Test/MyGenericRecord.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using Esiur.Data;
|
||||||
|
using Esiur.Resource;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Test
|
||||||
|
{
|
||||||
|
public class MyGenericRecord<T> : IRecord where T : IResource
|
||||||
|
{
|
||||||
|
[Public] public int Start { get; set; }
|
||||||
|
[Public] public int Needed { get; set; }
|
||||||
|
[Public] public int Total { get; set; }
|
||||||
|
[Public] public T[] Results { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,13 +20,6 @@ public enum SizeEnum:short
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class SearchResults<T> : IRecord where T : IResource
|
|
||||||
{
|
|
||||||
[Public] public int Offset { get; set; }
|
|
||||||
[Public] public int Needed { get; set; }
|
|
||||||
[Public] public int Total { get; set; }
|
|
||||||
[Public] public T[] Results { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[Resource]
|
[Resource]
|
||||||
public partial class MyService
|
public partial class MyService
|
||||||
@ -39,9 +32,9 @@ public partial class MyService
|
|||||||
[Public] bool[] booleanArray = new bool[] { true, false, true, false, true };
|
[Public] bool[] booleanArray = new bool[] { true, false, true, false, true };
|
||||||
|
|
||||||
[Public]
|
[Public]
|
||||||
public SearchResults<MyResource> GetRecords()
|
public MyGenericRecord<MyResource> GetGenericRecord()
|
||||||
{
|
{
|
||||||
return new SearchResults<MyResource>() { Needed = 3, Offset = 10, Results = new MyResource[0], Total = 102 };
|
return new MyGenericRecord<MyResource>() { Needed = 3, Start = 10, Results = new MyResource[0], Total = 102 };
|
||||||
}
|
}
|
||||||
|
|
||||||
[Public] byte uInt8Test = 8;
|
[Public] byte uInt8Test = 8;
|
||||||
|
@ -95,7 +95,9 @@ namespace Test
|
|||||||
dynamic remote = await Warehouse.Get<IResource>("iip://localhost/mem/service");
|
dynamic remote = await Warehouse.Get<IResource>("iip://localhost/mem/service");
|
||||||
|
|
||||||
TestObjectProps(local, remote);
|
TestObjectProps(local, remote);
|
||||||
var r = await remote.GetRecords();
|
|
||||||
|
var gr = await remote.GetGenericRecord();
|
||||||
|
Console.WriteLine(gr);
|
||||||
|
|
||||||
var opt = await remote.Optional(new { a1 = 22, a2 = 33, a4 = "What?" });
|
var opt = await remote.Optional(new { a1 = 22, a2 = 33, a4 = "What?" });
|
||||||
Console.WriteLine(opt);
|
Console.WriteLine(opt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user