Permalink
Browse files

Removed docstates file

  • Loading branch information...
2 parents bbcf28b + 5613a54 commit 36b2681ea0940f0fc6e250e441ed45e79af62f16 @markrendle committed Jun 19, 2011
View
@@ -14,6 +14,6 @@ TestResults/*
*.dbmdl
Releases/2*
*.pidb
-Simple.Data.sln.docstates
+*.docstates
test-results
apply_config.bat
@@ -67,6 +67,23 @@ public void TestFindLessThanOrEqualWithInt32()
}
[Test]
+ public void TestFindByNamedParameterSingleColumn()
+ {
+ _db.Users.FindBy(Name: "Foo");
+ GeneratedSqlIs("select [dbo].[Users].* from [dbo].[Users] where [dbo].[Users].[name] = @p1");
+ Parameter(0).Is("Foo");
+ }
+
+ [Test]
+ public void TestFindByNamedParameterTwoColumns()
+ {
+ _db.Users.FindBy(Name: "Foo", Password: "password");
+ GeneratedSqlIs("select [dbo].[Users].* from [dbo].[Users] where ([dbo].[Users].[name] = @p1 and [dbo].[Users].[password] = @p2)");
+ Parameter(0).Is("Foo");
+ Parameter(1).Is("password");
+ }
+
+ [Test]
public void TestFindByDynamicSingleColumn()
{
_db.Users.FindByName("Foo");
@@ -91,6 +108,24 @@ public void TestFindAllWithLike()
}
[Test]
+ public void TestFindAllByNamedParameterSingleColumn()
+ {
+ _db.Users.FindAllBy(Name: "Foo").ToList();
+ GeneratedSqlIs("select [dbo].[Users].[id],[dbo].[Users].[name],[dbo].[Users].[password],[dbo].[Users].[age] from [dbo].[Users] where [dbo].[Users].[name] = @p1");
+ Parameter(0).Is("Foo");
+ }
+
+ [Test]
+ public void TestFindAllByNamedParameterTwoColumns()
+ {
+ _db.Users.FindAllBy(Name: "Foo", Password: "password").ToList();
+ GeneratedSqlIs("select [dbo].[Users].[id],[dbo].[Users].[name],[dbo].[Users].[password],[dbo].[Users].[age] from [dbo].[Users] where ([dbo].[Users].[name] = @p1 and [dbo].[Users].[password] = @p2)");
+ Parameter(0).Is("Foo");
+ Parameter(1).Is("password");
+ }
+
+
+ [Test]
public void TestFindByDynamicTwoColumns()
{
_db.Users.FindByNameAndPassword("Foo", "secret");
Binary file not shown.
@@ -14,8 +14,16 @@ public bool IsCommandFor(string method)
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
- var criteria = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), MethodNameParser.ParseFromBinder(binder, args));
- return new SimpleQuery(dataStrategy.GetAdapter(), table.GetQualifiedName()).Where(criteria);
+ SimpleExpression criteriaExpression;
+ if (binder.Name.Equals("FindAllBy") || binder.Name.Equals("find_all_by"))
+ {
+ criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), binder.NamedArgumentsToDictionary(args));
+ }
+ else
+ {
+ criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), MethodNameParser.ParseFromBinder(binder, args));
+ }
+ return new SimpleQuery(dataStrategy.GetAdapter(), table.GetQualifiedName()).Where(criteriaExpression);
//var data = dataStrategy.Find(table.GetQualifiedName(), criteria);
//return CreateSimpleResultSet(table, dataStrategy, data);
}
@@ -17,7 +17,15 @@ public bool IsCommandFor(string method)
{
if (dataStrategy is SimpleTransaction) return null;
- var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), MethodNameParser.ParseFromBinder(binder, args));
+ SimpleExpression criteriaExpression;
+ if (binder.Name.Equals("FindBy") || binder.Name.Equals("find_by"))
+ {
+ criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), binder.NamedArgumentsToDictionary(args));
+ }
+ else
+ {
+ criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), MethodNameParser.ParseFromBinder(binder, args));
+ }
try
{
var func = dataStrategy.GetAdapter().CreateFindOneDelegate(table.GetQualifiedName(), criteriaExpression);

0 comments on commit 36b2681

Please sign in to comment.