SimpleRepository を使用して、非 ID プロパティに基づいてフェッチを実行しようとしています。私が使用している Customer クラスは次のとおりです。
[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 式のコンパイルのどの時点でこれがスローされるかはわかりませんが、この例を空のデータベースで実行しています。スキーマ世代は、テーブル構造を作成するのに十分な距離を取得しますが、式を評価できません。
私が間違っているかもしれないことを誰かが知っていますか?
ありがとう!