Why am I getting a runtime binder exception when trying to execute the following query in Massive?
public dynamic Find(string email, string type)
{
dynamic result = new ExpandoObject();
result = this.Query(@"SELECT * FROM Addresses a
INNER JOIN Members m ON m.Id = a.MemberId
INNER JOIN AddressType at ON at.Id = a.AddressTypeId
WHERE m.Email = @0 AND at.Type = @1", new {email, type});
return result;
}
EDIT TO SHOW SOLUTION: I needed to change my query to ensure only one column with the name 'Id' was returned. I was getting a binding error because multiple columns in Members and Addresses had a column named 'Id'. To get a single result in my query I had to modify it to this:
result = this.Query(@"SELECT a.* FROM Addresses a
INNER JOIN Members m ON m.Id = a.MemberId
INNER JOIN AddressType at ON at.Id = a.AddressTypeId
WHERE m.Email = @0 AND at.Type = @1", new object[] { email, type }).Single();
Hope this helps someone else.