public virtual async Task <bool> IsUniqueAsync(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 = await SlaveMongoCollection.FindAsync(filter); return(find.FirstOrDefault() == null); }
public virtual async Task <TEntity> FirstOrDefaultAsync(Expression <Func <TEntity, bool> > filter) { var x = await SlaveMongoCollection.FindAsync(SoftFilter(filter)); return(x.FirstOrDefault()); }
public virtual async Task <IEnumerable <TEntity> > FindAllAsync(Expression <Func <TEntity, bool> > filter) { var x = await SlaveMongoCollection.FindAsync(SoftFilter(filter)); return(x.ToList()); }