문제

I've the following Entity Framework entities:

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; }
}

Moles has generated MPerson and MCountry stub classes.

Now I do want to stub the set of the 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;
};
도움이 되었습니까?

해결책

This post gives the answer:

MolesContext.ExecuteWithoutMoles(() => instance.Country_Id = id);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top