public virtual bool IsUnique(TPrimaryKey id, string filedName, object value) { FilterDefinition <TEntity> filter; if (SoftDelete) { filter = Builders <TEntity> .Filter.And(Builders <TEntity> .Filter.Eq(filedName, value), Builders <TEntity> .Filter.Eq(i => ((ISoftDelete)i).IsDeleted, false)); } else { filter = Builders <TEntity> .Filter.Eq(filedName, value); } if (id != null && !string.IsNullOrWhiteSpace(id.ToString())) { filter = Builders <TEntity> .Filter.And(filter, Builders <TEntity> .Filter.Ne(m => m.Id, id)); } var find = SlaveMongoCollection.Find(filter); return(find.FirstOrDefault() == null); }
public virtual long Count(Expression <Func <TEntity, bool> > filter) { return(SlaveMongoCollection.Find(SoftFilter(filter)).Count()); }
public virtual TEntity FirstOrDefault(Expression <Func <TEntity, bool> > filter) { return(SlaveMongoCollection.Find(SoftFilter(filter)).FirstOrDefault()); }
public virtual async Task <bool> AnyAsync(Expression <Func <TEntity, bool> > filter) { return(await SlaveMongoCollection.Find(SoftFilter(filter)).AnyAsync()); }
public virtual IEnumerable <TEntity> FindAll(Expression <Func <TEntity, bool> > filter) { return(SlaveMongoCollection.Find(SoftFilter(filter)).ToList()); }