public static FilterDefinition <TEntity> CreateIdFilter <TEntity>(this IEntityDefinition definition, object entityId, string tenantId = null)
 {
     if (typeof(IHaveTenantId).IsAssignableFrom(typeof(TEntity)) && tenantId == null)
     {
         throw new ArgumentException("Tenant ID required for Tenant Entity");
     }
     if (tenantId == null)
     {
         return(Builders <TEntity> .Filter.Eq(definition.GetIdName(), entityId));
     }
     else
     {
         return(Builders <TEntity> .Filter.And(
                    Builders <TEntity> .Filter.Eq(definition.GetIdName(), entityId),
                    Builders <TEntity> .Filter.Eq("TenantId", tenantId)
                    ));
     }
 }
Exemplo n.º 2
0
 public static FilterDefinition <TEntity> CreateIdFilter <TEntity>(this IEntityDefinition definition, object entityId)
 {
     return(Builders <TEntity> .Filter.Eq(definition.GetIdName(), entityId));
 }
Exemplo n.º 3
0
 public static FilterDefinition <TEntity> CreateIdFilterFromEntity <TEntity>(this IEntityDefinition definition, TEntity entity)
 {
     return(Builders <TEntity> .Filter.Eq(definition.GetIdName(), definition.GetIdValue(entity)));
 }