Esempio n. 1
0
        internal static List <T> Select <T>(this IDbCommand dbCmd, SqlExpression <T> expression)
        {
            string sql = expression.SelectInto <T>();

            return(dbCmd.ExprConvertToList <T>(sql));
        }
Esempio n. 2
0
        internal static T Single <T>(this IDbCommand dbCmd, SqlExpression <T> expression)
        {
            string sql = expression.Limit(1).SelectInto <T>();

            return(dbCmd.ExprConvertTo <T>(sql));
        }
Esempio n. 3
0
 internal static List <Into> LoadSelect <Into, From>(this IDbCommand dbCmd, SqlExpression <From> expression)
 {
     return(dbCmd.LoadListWithReferences <Into, From>(expression));
 }
Esempio n. 4
0
 internal static List <T> LoadSelect <T>(this IDbCommand dbCmd, SqlExpression <T> expression = null)
 {
     return(dbCmd.LoadListWithReferences <T, T>(expression));
 }
Esempio n. 5
0
 internal static long RowCount <T>(this IDbCommand dbCmd, SqlExpression <T> expression)
 {
     return(dbCmd.Scalar <long>(dbCmd.GetDialectProvider().ToRowCountStatement(expression.ToSelectStatement())));
 }
Esempio n. 6
0
        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);
        }