0
SimpleRepositoryを使用して、ID以外のプロパティに基づいてフェッチを実行しようとしています。SimpleRepositoryのSingleメソッドを使用している "Lambda Parameter in scope"例外
[Serializable]
public class Customer : IEntity<Guid>
{
public Guid ProviderUserKey { get; set; }
public Guid ID
{
get; set;
}
}
私は移行を有効にしてSimpleRepositoryを使用しています。 「スコープにラムダパラメータではありません」スローコードは以下の通りです:
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式のコンパイル中にどの時点ではわからないんだけど、私は空のデータベースでこの例を実行しています。スキーマ世代は、テーブル構造を作成するのに十分な距離にありますが、式を評価することはできません。
誰かが私が間違っているかもしれないことを知っていますか?
ありがとうございます!
こんにちは、このエラーも出てきますが、Findメソッドを使用しています。 – ryudice
こんにちはRob私はSubSonic 3.0.4を使用していて、これをやろうとしています: 'x => x.FirstName.ToUpper()。StartsWith(name)' constraintfragmentがnullであるため、 'Constraint'を構築するときに例外をスローします。 ToUpperなしで動作する – TheVillageIdiot