Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
 public IDocumentProjectionBuilder Exclude(string property)
 {
     _projections.Add(InternalBuilder.Exclude(property));
     return(this);
 }