public int Count(IObjectFacade target) { if (IsCollection) { INakedObjectAdapter result = assoc.GetNakedObject(((ObjectFacade)target).WrappedNakedObject); return(result.GetCollectionFacetFromSpec().AsQueryable(result).Count()); } return(0); }
private INakedObjectAdapter Page(INakedObjectAdapter objectRepresentingCollection, int page, int size, bool forceEnumerable) { var toEnumerable = IsNotQueryable(objectRepresentingCollection) || forceEnumerable; var newNakedObject = objectRepresentingCollection.GetCollectionFacetFromSpec().Page(page, size, objectRepresentingCollection, framework.NakedObjectManager, toEnumerable); object[] objects = newNakedObject.GetAsEnumerable(framework.NakedObjectManager).Select(no => no.Object).ToArray(); var currentMemento = (ICollectionMemento)WrappedNakedObject.Oid; ICollectionMemento newMemento = currentMemento.NewSelectionMemento(objects, true); newNakedObject.SetATransientOid(newMemento); return(newNakedObject); }
public int CountField(INakedObjectAdapter nakedObjectAdapter, string field) { var spec = nakedObjectAdapter.Spec as IObjectSpec; Trace.Assert(spec != null); IAssociationSpec associationSpec = spec.Properties.Single(x => x.Id == field); if (nakedObjectAdapter.Spec.IsViewModel) { INakedObjectAdapter collection = associationSpec.GetNakedObject(nakedObjectAdapter); return(collection.GetCollectionFacetFromSpec().AsEnumerable(collection, nakedObjectManager).Count()); } return(objectStore.CountField(nakedObjectAdapter, associationSpec)); }
private INakedObjectAdapter Page(INakedObjectAdapter objectRepresentingCollection, int page, int size, bool forceEnumerable) { var toEnumerable = IsNotQueryable(objectRepresentingCollection) || forceEnumerable; var newNakedObject = objectRepresentingCollection.GetCollectionFacetFromSpec().Page(page, size, objectRepresentingCollection, framework.NakedObjectManager, toEnumerable); object[] objects = newNakedObject.GetAsEnumerable(framework.NakedObjectManager).Select(no => no.Object).ToArray(); var currentMemento = (ICollectionMemento) WrappedNakedObject.Oid; ICollectionMemento newMemento = currentMemento.NewSelectionMemento(objects, true); newNakedObject.SetATransientOid(newMemento); return newNakedObject; }
public static IQueryable GetAsQueryable(this INakedObjectAdapter objectAdapterRepresentingCollection) { return(objectAdapterRepresentingCollection.GetCollectionFacetFromSpec().AsQueryable(objectAdapterRepresentingCollection)); }
public static IEnumerable <INakedObjectAdapter> GetAsEnumerable(this INakedObjectAdapter objectAdapterRepresentingCollection, INakedObjectManager manager) { return(objectAdapterRepresentingCollection.GetCollectionFacetFromSpec().AsEnumerable(objectAdapterRepresentingCollection, manager)); }