internal static List <T> Select <T>(this IDbCommand dbCmd, SqlExpression <T> expression) { string sql = expression.SelectInto <T>(); return(dbCmd.ExprConvertToList <T>(sql)); }
internal static T Single <T>(this IDbCommand dbCmd, SqlExpression <T> expression) { string sql = expression.Limit(1).SelectInto <T>(); return(dbCmd.ExprConvertTo <T>(sql)); }
internal static List <Into> LoadSelect <Into, From>(this IDbCommand dbCmd, SqlExpression <From> expression) { return(dbCmd.LoadListWithReferences <Into, From>(expression)); }
internal static List <T> LoadSelect <T>(this IDbCommand dbCmd, SqlExpression <T> expression = null) { return(dbCmd.LoadListWithReferences <T, T>(expression)); }
internal static long RowCount <T>(this IDbCommand dbCmd, SqlExpression <T> expression) { return(dbCmd.Scalar <long>(dbCmd.GetDialectProvider().ToRowCountStatement(expression.ToSelectStatement()))); }
internal static long Count <T>(this IDbCommand dbCmd, SqlExpression <T> expression) { var sql = expression.ToCountStatement(); return(GetCount(dbCmd, sql)); }
internal static List <Into> LoadListWithReferences <Into, From>(this IDbCommand dbCmd, SqlExpression <From> expr = null, IEnumerable <string> include = null) { var loadList = new LoadListSync <Into, From>(dbCmd, expr); var fieldDefs = loadList.FieldDefs; var includeSet = include != null ? new HashSet <string>(include, StringComparer.OrdinalIgnoreCase) : null; foreach (var fieldDef in fieldDefs) { if (includeSet != null && !includeSet.Contains(fieldDef.Name)) { continue; } var listInterface = fieldDef.FieldType.GetTypeWithGenericInterfaceOf(typeof(IList <>)); if (listInterface != null) { loadList.SetRefFieldList(fieldDef, listInterface.GetGenericArguments()[0]); } else { loadList.SetRefField(fieldDef, fieldDef.FieldType); } } return(loadList.ParentResults); }