Exemple #1
0
 internal LiteCollection(string name, DbEngine engine, BsonMapper mapper, Logger log)
 {
     _name     = name;
     _engine   = engine;
     _mapper   = mapper;
     _log      = log;
     _visitor  = new QueryVisitor <T>(mapper);
     _includes = new List <Action <BsonDocument> >();
 }
Exemple #2
0
 public LiteCollection(string name, LazyLoad <LiteEngine> engine, BsonMapper mapper, LoggerWrap log)
 {
     _name     = name ?? mapper.ResolveCollectionName(typeof(T));
     _engine   = engine;
     _mapper   = mapper;
     _log      = log;
     _visitor  = new QueryVisitor <T>(mapper);
     _includes = new List <Action <BsonDocument> >();
 }
Exemple #3
0
 /// <summary>
 /// Find the first document using Linq expression. Returns null if not found. Must have indexes on predicate.
 /// </summary>
 public T FindOne(Expression <Func <T, bool> > predicate)
 {
     return(this.Find(QueryVisitor.Visit(predicate)).FirstOrDefault());
 }
Exemple #4
0
 /// <summary>
 /// Returns true if query returns any document. This method does not deserialize any document. Needs indexes on query expression
 /// </summary>
 public bool Exists(Expression <Func <T, bool> > predicate)
 {
     return(this.Exists(QueryVisitor.Visit(predicate)));
 }
Exemple #5
0
 /// <summary>
 /// Count documnets with a query. This method does not deserialize any document. Needs indexes on query expression
 /// </summary>
 public int Count(Expression <Func <T, bool> > predicate)
 {
     return(this.Count(QueryVisitor.Visit(predicate)));
 }
Exemple #6
0
 /// <summary>
 /// Find documents inside a collection using Linq expression. Must have indexes in linq expression
 /// </summary>
 public IEnumerable <T> Find(Expression <Func <T, bool> > predicate)
 {
     return(this.Find(QueryVisitor.Visit(predicate)));
 }
Exemple #7
0
        /// <summary>
        /// Create a new permanent index in all documents inside this collections if index not exists already.
        /// </summary>
        /// <param name="property">Property linq expression</param>
        /// <param name="unique">Create a unique values index?</param>
        public virtual bool EnsureIndex <K>(Expression <Func <T, K> > property, bool unique = false)
        {
            var p = QueryVisitor.GetProperty <T, K>(property);

            return(this.EnsureIndex(p.Name, unique));
        }
Exemple #8
0
 /// <summary>
 /// Delete document based on a LINQ query.
 /// </summary>
 public virtual int Delete(Expression <Func <T, bool> > predicate)
 {
     return(this.Delete(QueryVisitor.Visit(predicate)));
 }