Skip to content
Browse files

Fixed issue #168 (FindBy named parameters InMemoryAdapter)

  • Loading branch information...
1 parent df48771 commit c86482a5a210769f978a21832799413a63cf68f4 @markrendle markrendle committed Mar 16, 2012
Showing with 15 additions and 1 deletion.
  1. +12 −0 Simple.Data.InMemoryTest/InMemoryTests.cs
  2. +3 −1 Simple.Data/Commands/FindByCommand.cs
View
12 Simple.Data.InMemoryTest/InMemoryTests.cs
@@ -48,6 +48,18 @@ public void InsertAndFindWithTwoColumnsShouldWork()
}
[Test]
+ public void InsertAndFindWithTwoColumnsUsingNamedParametersShouldWork()
+ {
+ Database.UseMockAdapter(new InMemoryAdapter());
+ var db = Database.Open();
+ db.Test.Insert(Id: 1, Name: "Alice");
+ var record = db.Test.FindBy(Id: 1, Name: "Alice");
+ Assert.IsNotNull(record);
+ Assert.AreEqual(1, record.Id);
+ Assert.AreEqual("Alice", record.Name);
+ }
+
+ [Test]
public void AllShouldReturnAllRecords()
{
Database.UseMockAdapter(new InMemoryAdapter());
View
4 Simple.Data/Commands/FindByCommand.cs
@@ -60,7 +60,9 @@ public bool IsCommandFor(string method)
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
- var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), MethodNameParser.ParseFromBinder(binder, args));
+ var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(),
+ CreateCriteriaDictionary(binder,
+ args));
var data = dataStrategy.FindOne(table.GetQualifiedName(), criteriaExpression);
return data != null ? new SimpleRecord(data, table.GetQualifiedName(), dataStrategy) : null;
}

0 comments on commit c86482a

Please sign in to comment.
Something went wrong with that request. Please try again.