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) )); } }
public static FilterDefinition <TEntity> CreateIdFilter <TEntity>(this IEntityDefinition definition, object entityId) { return(Builders <TEntity> .Filter.Eq(definition.GetIdName(), entityId)); }
public static FilterDefinition <TEntity> CreateIdFilterFromEntity <TEntity>(this IEntityDefinition definition, TEntity entity) { return(Builders <TEntity> .Filter.Eq(definition.GetIdName(), definition.GetIdValue(entity))); }