internal static void PopulateWith(this IDbCommand dbCmd, ISqlExpression expression)
 {
     dbCmd.CommandText = expression.ToSelectStatement(); //needs to evaluate SQL before setting params
     dbCmd.SetParameters(expression.Params);
 }
コード例 #2
0
 /// <summary>
 /// Returns a single scalar value using an SqlExpression. E.g:
 /// <para>db.Column&lt;int&gt;(db.From&lt;Persion&gt;().Select(x => Sql.Count("*")).Where(q => q.Age > 40))</para>
 /// </summary>
 public static T Scalar <T>(this IDbConnection dbConn, ISqlExpression sqlExpression)
 {
     return(dbConn.Exec(dbCmd => dbCmd.Scalar <T>(sqlExpression.ToSelectStatement(), sqlExpression.Params)));
 }
コード例 #3
0
 /// <summary>
 /// Returns a list of KeyValuePairs from the first 2 columns: Column 1 (Keys), Column 2 (Values) using an SqlExpression. E.g:
 /// <para>db.KeyValuePairsAsync&lt;int, string&gt;(db.From&lt;Person&gt;().Select(x => new { x.Id, x.LastName }).Where(x => x.Age < 50))</para>
 /// </summary>
 public static Task <List <KeyValuePair <K, V> > > KeyValuePairsAsync <K, V>(this IDbConnection dbConn, ISqlExpression query, CancellationToken token = default)
 {
     return(dbConn.Exec(dbCmd => dbCmd.KeyValuePairsAsync <K, V>(query.ToSelectStatement(), query.Params, token)));
 }
コード例 #4
0
 /// <summary>
 /// Returns a single Scalar value using an SqlExpression. E.g:
 /// <para>db.SqlScalarAsync&lt;int&gt;(db.From&lt;Person&gt;().Select(Sql.Count("*")).Where(q => q.Age &lt; 50))</para>
 /// </summary>
 public static Task <T> SqlScalarAsync <T>(this IDbConnection dbConn, ISqlExpression sqlExpression, CancellationToken token = default)
 {
     return(dbConn.Exec(dbCmd => dbCmd.SqlScalarAsync <T>(sqlExpression.ToSelectStatement(), sqlExpression.Params, token)));
 }
コード例 #5
0
 /// <summary>
 /// Returns an Dictionary&lt;K, List&lt;V&gt;&gt; grouping made from the first two columns using an Sql Expression. E.g:
 /// <para>db.LookupAsync&lt;int, string&gt;(db.From&lt;Person&gt;().Select(x => new { x.Age, x.LastName }).Where(q => q.Age < 50))</para>
 /// </summary>
 public static Task <Dictionary <K, List <V> > > LookupAsync <K, V>(this IDbConnection dbConn, ISqlExpression sqlExpression, CancellationToken token = default)
 {
     return(dbConn.Exec(dbCmd => dbCmd.LookupAsync <K, V>(sqlExpression.ToSelectStatement(), sqlExpression.Params, token)));
 }
コード例 #6
0
 /// <summary>
 /// Returns a Dictionary from the first 2 columns: Column 1 (Keys), Column 2 (Values) using an SqlExpression. E.g:
 /// <para>db.DictionaryAsync&lt;int, string&gt;(db.From&lt;Person&gt;().Select(x => new { x.Id, x.LastName }).Where(x => x.Age < 50))</para>
 /// </summary>
 public static Task <Dictionary <K, V> > DictionaryAsync <K, V>(this IDbConnection dbConn, ISqlExpression query, CancellationToken token = default)
 {
     return(dbConn.Exec(dbCmd => dbCmd.DictionaryAsync <K, V>(query.ToSelectStatement(), query.Params, token)));
 }
コード例 #7
0
ファイル: OrmLiteReadApi.cs プロジェクト: stantoxt/YAFNET
 /// <summary>
 /// Returns the first column in a List using an SqlExpression. E.g:
 /// <para>db.SqlColumn&lt;string&gt;(db.From&lt;Person&gt;().Select(x => x.LastName).Where(q => q.Age < 50))</para>
 /// </summary>
 public static List <T> SqlColumn <T>(this IDbConnection dbConn, ISqlExpression sqlExpression)
 {
     return(dbConn.Exec(dbCmd => dbCmd.SqlColumn <T>(sqlExpression.ToSelectStatement())));
 }
コード例 #8
0
 /// <summary>
 /// Returns the distinct first column values in a HashSet using an SqlExpression. E.g:
 /// <para>db.ColumnDistinctAsync&lt;int&gt;(db.From&lt;Person&gt;().Select(x => x.Age).Where(q => q.Age < 50))</para>
 /// </summary>
 public static Task <HashSet <T> > ColumnDistinctAsync <T>(this IDbConnection dbConn, ISqlExpression query, CancellationToken token = default)
 {
     return(dbConn.Exec(dbCmd => dbCmd.ColumnDistinctAsync <T>(query.ToSelectStatement(), query.Params, token)));
 }
コード例 #9
0
ファイル: OrmLiteReadApi.cs プロジェクト: stantoxt/YAFNET
 /// <summary>
 /// Returns an Dictionary&lt;K, List&lt;V&gt;&gt; grouping made from the first two columns using an Sql Expression. E.g:
 /// <para>db.Lookup&lt;int, string&gt;(db.From&lt;Person&gt;().Select(x => new { x.Age, x.LastName }).Where(q => q.Age < 50))</para>
 /// </summary>
 public static Dictionary <K, List <V> > Lookup <K, V>(this IDbConnection dbConn, ISqlExpression sqlExpression)
 {
     return(dbConn.Exec(dbCmd => dbCmd.Lookup <K, V>(sqlExpression.ToSelectStatement())));
 }
コード例 #10
0
ファイル: OrmLiteReadApi.cs プロジェクト: stantoxt/YAFNET
 /// <summary>
 /// Returns a Dictionary from the first 2 columns: Column 1 (Keys), Column 2 (Values) using an SqlExpression. E.g:
 /// <para>db.Dictionary&lt;int, string&gt;(db.From&lt;Person&gt;().Select(x => new { x.Id, x.LastName }).Where(x => x.Age < 50))</para>
 /// </summary>
 public static Dictionary <K, V> Dictionary <K, V>(this IDbConnection dbConn, ISqlExpression query)
 {
     return(dbConn.Exec(dbCmd => dbCmd.Dictionary <K, V>(query.ToSelectStatement())));
 }
コード例 #11
0
ファイル: OrmLiteReadApi.cs プロジェクト: stantoxt/YAFNET
 /// <summary>
 /// Returns the distinct first column values in a HashSet using an SqlExpression. E.g:
 /// <para>db.ColumnDistinct&lt;int&gt;(db.From&lt;Persion&gt;().Select(x => x.Age).Where(q => q.Age < 50))</para>
 /// </summary>
 public static HashSet <T> ColumnDistinct <T>(this IDbConnection dbConn, ISqlExpression query)
 {
     return(dbConn.Exec(dbCmd => dbCmd.ColumnDistinct <T>(query.ToSelectStatement())));
 }
コード例 #12
0
ファイル: OrmLiteReadApi.cs プロジェクト: stantoxt/YAFNET
 /// <summary>
 /// Returns the distinct first column values in a HashSet using an SqlExpression. E.g:
 /// <para>db.ColumnLazy&lt;int&gt;(db.From&lt;Persion&gt;().Select(x => x.LastName).Where(q => q.Age == 27))</para>
 /// </summary>
 public static IEnumerable <T> ColumnLazy <T>(this IDbConnection dbConn, ISqlExpression query)
 {
     return(dbConn.ExecLazy(dbCmd => dbCmd.ColumnLazy <T>(query.ToSelectStatement())));
 }
コード例 #13
0
 /// <summary>
 /// Returns results from an arbitrary SqlExpression. E.g:
 /// <para>db.SqlList&lt;Person&gt;(db.From&lt;Person&gt;().Select("*").Where(q => q.Age &lt; 50))</para>
 /// </summary>
 public static List <T> SqlList <T>(this IDbConnection dbConn, ISqlExpression sqlExpression)
 {
     return(dbConn.Exec(dbCmd => dbCmd.SqlList <T>(sqlExpression.ToSelectStatement(QueryType.Select), sqlExpression.Params)));
 }
コード例 #14
0
 /// <summary>
 /// Returns the distinct first column values in a HashSet using an SqlExpression. E.g:
 /// <para>db.Column&lt;int&gt;(db.From&lt;Person&gt;().Select(x => x.LastName).Where(q => q.Age == 27))</para>
 /// </summary>
 public static List <T> Column <T>(this IDbConnection dbConn, ISqlExpression query)
 {
     return(dbConn.Exec(dbCmd => dbCmd.Column <T>(query.ToSelectStatement(QueryType.Select), query.Params)));
 }
コード例 #15
0
 /// <summary>
 /// Returns results from using an SqlExpression lambda. E.g:
 /// <para>db.Select(db.From&lt;Person&gt;().Where(x =&gt; x.Age &gt; 40))</para>
 /// </summary>
 public static List <T> Select <T>(this IDbConnection dbConn, ISqlExpression expression, object anonType = null)
 {
     return(dbConn.Exec(dbCmd => dbCmd.SqlList <T>(expression.ToSelectStatement(), anonType)));
 }