protected virtual async Task <int> Delete <TEntity>(Expression <Func <TEntity, bool> > condition, string table, bool @async) { PublicHelper.CheckNull(condition); TypeDescriptor typeDescriptor = EntityTypeContainer.GetDescriptor(typeof(TEntity)); DbTable dbTable = typeDescriptor.GenDbTable(table); DefaultExpressionParser expressionParser = typeDescriptor.GetExpressionParser(dbTable); DbExpression conditionExp = expressionParser.ParseFilterPredicate(condition); DbDeleteExpression e = new DbDeleteExpression(dbTable, conditionExp); return(await this.ExecuteNonQuery(e, @async)); }
static QueryModel CreateQueryModel(RootQueryExpression rootQueryExp, ScopeParameterDictionary scopeParameters, StringSet scopeTables, Func <string, string> tableAliasGenerator) { Type entityType = rootQueryExp.ElementType; if (entityType.IsAbstract || entityType.IsInterface) { throw new ArgumentException("The type of input can not be abstract class or interface."); } QueryModel queryModel = new QueryModel(scopeParameters, scopeTables); TypeDescriptor typeDescriptor = EntityTypeContainer.GetDescriptor(entityType); DbTable dbTable = typeDescriptor.GenDbTable(rootQueryExp.ExplicitTable); string alias = null; if (tableAliasGenerator != null) { alias = tableAliasGenerator(dbTable.Name); } else { alias = queryModel.GenerateUniqueTableAlias(dbTable.Name); } queryModel.FromTable = CreateRootTable(dbTable, alias, rootQueryExp.Lock); DbTable aliasTable = new DbTable(alias); ComplexObjectModel model = typeDescriptor.GenObjectModel(aliasTable); model.DependentTable = queryModel.FromTable; queryModel.ResultModel = model; ParseFilters(queryModel, typeDescriptor.Definition.Filters, rootQueryExp.ContextFilters); return(queryModel); }
public static DbTable CreateDbTable(TypeDescriptor typeDescriptor, string table) { return(typeDescriptor.GenDbTable(table)); }