diff --git a/Esiur.Stores.EntityCore/EsiurExtensions.cs b/Esiur.Stores.EntityCore/EsiurExtensions.cs index 8f76ec8..f81dda0 100644 --- a/Esiur.Stores.EntityCore/EsiurExtensions.cs +++ b/Esiur.Stores.EntityCore/EsiurExtensions.cs @@ -54,6 +54,9 @@ public static class EsiurExtensions { var store = dbSet.GetInfrastructure().GetService().FindExtension().Store; + if (store == null) + throw new Exception("Store not set, please call 'UseEsiur' on your DbContextOptionsBuilder."); + if (!store.Initialized) throw new Exception("Store not initialized. Make sure the Warehouse is open"); diff --git a/Test/MyGenericRecord.cs b/Test/MyGenericRecord.cs new file mode 100644 index 0000000..782ea5f --- /dev/null +++ b/Test/MyGenericRecord.cs @@ -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 : 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; } + } + +} diff --git a/Test/MyService.cs b/Test/MyService.cs index 10934d0..439597b 100644 --- a/Test/MyService.cs +++ b/Test/MyService.cs @@ -20,13 +20,6 @@ public enum SizeEnum:short } -public class SearchResults : 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] public partial class MyService @@ -39,9 +32,9 @@ public partial class MyService [Public] bool[] booleanArray = new bool[] { true, false, true, false, true }; [Public] - public SearchResults GetRecords() + public MyGenericRecord GetGenericRecord() { - return new SearchResults() { Needed = 3, Offset = 10, Results = new MyResource[0], Total = 102 }; + return new MyGenericRecord() { Needed = 3, Start = 10, Results = new MyResource[0], Total = 102 }; } [Public] byte uInt8Test = 8; diff --git a/Test/Program.cs b/Test/Program.cs index 9db709f..6b7ccd4 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -95,7 +95,9 @@ namespace Test dynamic remote = await Warehouse.Get("iip://localhost/mem/service"); 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?" }); Console.WriteLine(opt);