/// <summary> /// splits items out from a store and creates a new store for them /// </summary> /// <param name="store"></param> /// <param name="itemsToRemove"></param> public static NaturalInMemoryStore SplitFromStore(this IStore store, List <StoredObjectId> itemsToRemove) { if (store == null) { return(null); } if (itemsToRemove == null || itemsToRemove.Count == 0) { return(null); } NaturalInMemoryStore returnValue = new NaturalInMemoryStore(); itemsToRemove.WithEach(x => { var item = store.Get(x); if (item != null) { //move the item from one store to the other returnValue.SaveItem(item); store.DeleteItem(item.GetStoredObjectId()); } }); return(returnValue); }
/// <summary> /// splits items out from a store and creates a new store for them /// </summary> /// <param name="store"></param> /// <param name="itemsToRemove"></param> public static NaturalInMemoryStore SplitFromStore(this IStore store, List<StoredObjectId> itemsToRemove) { if (store == null) return null; if (itemsToRemove == null || itemsToRemove.Count == 0) return null; NaturalInMemoryStore returnValue = new NaturalInMemoryStore(); itemsToRemove.WithEach(x => { var item = store.Get(x); if (item != null) { //move the item from one store to the other returnValue.SaveItem(item); store.DeleteItem(item.GetStoredObjectId()); } }); return returnValue; }