protected string GetRefListSql(ModelDefinition refModelDef, FieldDefinition refField) { var sqlRef = $"SELECT {dialectProvider.GetColumnNames(refModelDef)} " + $"FROM {dialectProvider.GetQuotedTableName(refModelDef)} " + $"WHERE {dialectProvider.GetQuotedColumnName(refField)} " + $"IN ({subSql})"; return(sqlRef); }
protected string GetRefListSql(ModelDefinition refModelDef, FieldDefinition refField) { var sqlRef = "SELECT {0} FROM {1} WHERE {2} IN ({3})".Fmt( dialectProvider.GetColumnNames(refModelDef), dialectProvider.GetQuotedTableName(refModelDef), dialectProvider.GetQuotedColumnName(refField), subSql); return(sqlRef); }
protected string GetRefListSql(ModelDefinition refModelDef, FieldDefinition refField) { var sqlRef = $"SELECT {dialectProvider.GetColumnNames(refModelDef)} " + $"FROM {dialectProvider.GetQuotedTableName(refModelDef)} " + $"WHERE {dialectProvider.GetQuotedColumnName(refField)} " + $"IN ({subSql})"; if (OrmLiteConfig.LoadReferenceSelectFilter != null) { sqlRef = OrmLiteConfig.LoadReferenceSelectFilter(refModelDef.ModelType, sqlRef); } return(sqlRef); }
internal static string ToSelect <TModel>(IOrmLiteDialectProvider dialectProvider, Type fromTableType, string sqlFilter) { var sql = StringBuilderCache.Allocate(); var modelDef = ModelDefinition <TModel> .Definition; sql.AppendFormat("SELECT {0} FROM {1}", dialectProvider.GetColumnNames(modelDef), dialectProvider.GetQuotedTableName(fromTableType.GetModelDefinition())); if (!string.IsNullOrEmpty(sqlFilter)) { sql.Append(" WHERE "); sql.Append(sqlFilter); } return(StringBuilderCache.ReturnAndFree(sql)); }
internal static StringBuilder ToSelectFmt <TModel>(IOrmLiteDialectProvider dialectProvider, Type fromTableType, string sqlFilter, object[] filterParams) { var sql = new StringBuilder(); var modelDef = ModelDefinition <TModel> .Definition; sql.AppendFormat("SELECT {0} FROM {1}", dialectProvider.GetColumnNames(modelDef), dialectProvider.GetQuotedTableName(fromTableType.GetModelDefinition())); if (!string.IsNullOrEmpty(sqlFilter)) { sqlFilter = sqlFilter.SqlFmt(filterParams); sql.Append(" WHERE "); sql.Append(sqlFilter); } return(sql); }
internal static string ToSelect <TModel>(IOrmLiteDialectProvider dialectProvider, Type fromTableType, string sqlFilter, Expression <Func <TModel, object> > onlyFields = null) { var sql = StringBuilderCache.Allocate(); var modelDef = onlyFields != null ? ModelDefinition <TModel> .DynamicDefinition(onlyFields.GetFieldNames().ToList()) : ModelDefinition <TModel> .Definition; sql.Append( $"SELECT {dialectProvider.GetColumnNames(modelDef)} " + $"FROM {dialectProvider.GetQuotedTableName(fromTableType.GetModelDefinition())}"); if (string.IsNullOrEmpty(sqlFilter)) { return(StringBuilderCache.ReturnAndFree(sql)); } sql.Append(" WHERE "); sql.Append(sqlFilter); return(StringBuilderCache.ReturnAndFree(sql)); }
public static string GetColumnNames(this ModelDefinition modelDef, IOrmLiteDialectProvider dialect) { return(dialect.GetColumnNames(modelDef)); }