From 52e63b40e03f74f67e2edc150f3a6791fdf0fc7c Mon Sep 17 00:00:00 2001 From: Harald Wolff Date: Mon, 24 Feb 2020 17:31:33 +0100 Subject: [PATCH] Add Mapper.Count, Mapper.LoadArray(..) --- odb/ng/Mapper.API.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/odb/ng/Mapper.API.cs b/odb/ng/Mapper.API.cs index 240aa5d..717e488 100644 --- a/odb/ng/Mapper.API.cs +++ b/odb/ng/Mapper.API.cs @@ -23,7 +23,16 @@ namespace ln.types.odb.ng { return new MappedObjectEnumeration(this, type, GetDocumentIDs(type),refresh); } - + public object[] LoadArray(Type type) => LoadArray(type, false); + public object[] LoadArray(Type type, bool refresh) + { + MappedObjectEnumeration mappedObjectEnumeration = new MappedObjectEnumeration(this, type, GetDocumentIDs(type), refresh); + object[] objects = new object[mappedObjectEnumeration.Count]; + int n = 0; + foreach (object o in mappedObjectEnumeration) + objects[n++] = o; + return objects; + } public T Load(Guid documentID) => (T)Load(typeof(T), documentID, false); public T Load(Guid documentID,bool refresh) => (T)Load(typeof(T), documentID, refresh); public object Load(Type type, Guid documentID) => Load(type, documentID, false); @@ -40,7 +49,6 @@ namespace ln.types.odb.ng } else { - IStorage storage = StorageContainer.GetStorage(type.FullName); Document document = storage.Load(documentID); @@ -190,6 +198,8 @@ namespace ln.types.odb.ng IEnumerable documentIDs; bool refresh; + public int Count => documentIDs.Count(); + public MappedObjectEnumeration(Mapper mapper,Type type,IEnumerable documentIDs,bool refresh) { this.mapper = mapper;