Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 4d253e0

Browse files
committed
Add more readable and convenient From alias for creating a typed SqlExpression
1 parent 3677171 commit 4d253e0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/ServiceStack.OrmLite/Expressions/ReadConnectionExtensions.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ public static SqlExpression<T> SqlExpression<T>(this IDbConnection dbConn)
3333
return OrmLiteConfig.ExecFilter.SqlExpression<T>(dbConn);
3434
}
3535

36+
/// <summary>
37+
/// Creates a new SqlExpression builder allowing typed LINQ-like queries.
38+
/// Alias for SqlExpression.
39+
/// </summary>
40+
public static SqlExpression<T> From<T>(this IDbConnection dbConn)
41+
{
42+
return OrmLiteConfig.ExecFilter.SqlExpression<T>(dbConn);
43+
}
44+
45+
/// <summary>
46+
/// Creates a new SqlExpression builder for the specified type using a user-defined FROM sql expression.
47+
/// </summary>
48+
public static SqlExpression<T> From<T>(this IDbConnection dbConn, string fromExpression)
49+
{
50+
var expr = OrmLiteConfig.ExecFilter.SqlExpression<T>(dbConn);
51+
expr.From(fromExpression);
52+
return expr;
53+
}
54+
3655
/// <summary>
3756
/// Open a Transaction in OrmLite
3857
/// </summary>

0 commit comments

Comments
 (0)