public virtual int Count <T>(ISpecification <T> spec) { MongoSpecification <T> mongoSpec = (MongoSpecification <T>)spec; var cq = mongoSpec.GetQuery(); if (mongoSpec.CriteriaExpression != null) { cq = cq.Where(mongoSpec.CriteriaExpression); } return(cq.Count()); }
public virtual PagingResult <T> FindPaging <T>(ISpecification <T> spec) { MongoSpecification <T> mongoSpec = (MongoSpecification <T>)spec; int count = 0; if (mongoSpec.Take > 0) { var cq = mongoSpec.GetQuery(); if (mongoSpec.CriteriaExpression != null) { cq = cq.Where(mongoSpec.CriteriaExpression); } count = cq.Count(); } PagingResult <T> result = new PagingResult <T>(count); result.AddRange(mongoSpec.Query.ToList()); return(result); }