0

読み取り専用プロパティで使用する.CheckProperty場合は使用できますか?PersistenceSpecification

たとえば、プロパティを設定するメソッドUsedとして、読み取り専用プロパティを持つクラス:SetAsUsed

public class MyClass
{
    public virtual int Id { get; set; }
    public virtual string Code { get; set; }

    public virtual DateTime? Used { get; private set; }

    public virtual void SetAsUsed()
    {
        Used = DateTime.Now;
    }
}

次のような永続化仕様を作成したいと思います。

new PersistenceSpecification<ForgotPasswordRequest>(Session)
    .CheckProperty(x => x.Code, "a@b.com")
    .CheckProperty(x => x.Used, //??
    .VerifyTheMappings();

しかし、ここからメソッドを呼び出す方法がわかりませんかSetAsUsed?

4

1 に答える 1

0

私の頭の上から:

new PersistenceSpecification<ForgotPasswordRequest>(Session)
    .CheckProperty(x => x.Code, "a@b.com")
    .CheckProperty(x => x.Used, DateTime.Now, (entity, DateTime?) => entity.SetAsUsed())
    .VerifyTheMappings();
于 2013-07-04T22:03:32.777 に答える