我正在尝试使用 SimpleRepository 来执行基于非 ID 属性的提取。这是我正在使用的客户类:
[Serializable]
public class Customer : IEntity<Guid>
{
public Guid ProviderUserKey { get; set; }
public Guid ID
{
get; set;
}
}
我正在使用 SimpleRepository 并打开了迁移。抛出“Lambda 参数不在范围内”的代码如下:
public class CustomerRepository :
ICustomerRepository
{
private readonly IRepository _impl;
public CustomerRepository(string connectionStringName)
{
_impl = new SimpleRepository(connectionStringName,
SimpleRepositoryOptions.RunMigrations);
}
public Customer GetCustomer(string userName)
{
var user = Membership.GetUser(userName);
// Code to guard against a missing user would go here
// This line throws the exception
var customer = _impl.Single<Customer>(c => c.ProviderUserKey.Equals(user.ProviderUserKey));
// Code to create a new customer based on the
// ASP.NET Membership user would go here
return customer;
}
}
我不确定这会在 LINQ 表达式编译中的哪一点引发,但我正在一个空数据库上运行这个示例。模式生成足够远来创建表结构,但无法评估表达式。
有谁知道我可能做错了什么?
谢谢!