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

Commit 768d3aa

Browse files
committed
Merge pull request #295 from madaleno/master
Add overloaded ByExampleWhere<T>() method with excludeNulls parameter
2 parents fa3fe3f + 7c1d914 commit 768d3aa

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/ServiceStack.OrmLite/OrmLiteReadConnectionExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ public static List<T> ByExampleWhere<T>(this IDbConnection dbConn, object anonTy
200200
return dbConn.Exec(dbCmd => dbCmd.ByExampleWhere<T>(anonType));
201201
}
202202

203+
public static List<T> ByExampleWhere<T>(this IDbConnection dbConn, object anonType, bool excludeNulls)
204+
{
205+
return dbConn.Exec(dbCmd => dbCmd.ByExampleWhere<T>(anonType, excludeNulls));
206+
}
207+
203208
public static List<T> QueryByExample<T>(this IDbConnection dbConn, string sql, object anonType = null)
204209
{
205210
return dbConn.Exec(dbCmd => dbCmd.QueryByExample<T>(sql, anonType));

src/ServiceStack.OrmLite/OrmLiteReadExtensions.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,14 @@ internal static T SqlScalar<T>(this IDbCommand dbCmd, string sql, Dictionary<str
452452
return GetScalar<T>(dbReader);
453453
}
454454

455-
internal static List<T> ByExampleWhere<T>(this IDbCommand dbCmd, object anonType)
455+
internal static List<T> ByExampleWhere<T>(this IDbCommand dbCmd, object anonType)
456+
{
457+
return ByExampleWhere<T>(dbCmd, anonType, false);
458+
}
459+
460+
internal static List<T> ByExampleWhere<T>(this IDbCommand dbCmd, object anonType, bool excludeNulls)
456461
{
457-
dbCmd.SetFilters<T>(anonType, excludeNulls: false);
462+
dbCmd.SetFilters<T>(anonType, excludeNulls);
458463

459464
using (var dbReader = dbCmd.ExecuteReader())
460465
return dbReader.ConvertToList<T>();

0 commit comments

Comments
 (0)