public IEnumerable <Course> GetTrending() { var fields = CourseFieldBuilder .Exclude(c => c.Id) .Exclude(c => c.Duration) .Exclude(c => c.Sections) .Exclude(c => c.FullDescription) .Exclude(c => c.Prerequisites); var all = _courseCollection .Find(c => true) .Project <Course>(fields) .ToList(); return(all); }
private static async Task ThrowForOtherEtag(IMongoCollection <BsonDocument> collection, string key, string etag, Exception ex) { var existingEtag = await collection.Find(Filter.Eq(FieldId, key)) .Project <BsonDocument>(Projection.Exclude(FieldDoc)).FirstOrDefaultAsync(); if (existingEtag != null && existingEtag.Contains(FieldEtag)) { throw new InconsistentStateException(existingEtag[FieldEtag].AsString, etag, ex); } }
public IDocumentProjectionBuilder Exclude(string property) { _projections.Add(InternalBuilder.Exclude(property)); return(this); }