質問

次のエンティティフレームワークエンティティがあります。

public class Country
{
    public long Id { get; set; }
    public string Code { get; set; }
    public virtual ICollection<Person> Persons { get; set; }
}

public class Person
{
    public long Id { get; set; }
    public long? Country_Id { get; set; }
    public Country HomeCountry { get; set; }
}

モールが生成されました mpersonMcountry スタブクラス。

今、私はcountry_idのセットをスタブしたいです:

MPerson.AllInstances.Country_IdSetNullableOfInt64 = (Person instance, long? id) =>
{
    // Do something

    // Set the Country_Id to the provided id
    // This will trigger this same method again and again. How to avoid this ?
    instance.Country_Id = id;
};
役に立ちましたか?

解決

この郵便受け 答えを与える:

MolesContext.ExecuteWithoutMoles(() => instance.Country_Id = id);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top