Microsoft Moles: ошибка круговой ссылки? - PullRequest
0 голосов
/ 17 февраля 2012

У меня есть следующие сущности Entity Framework:

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

Кроты породили MPerson и MCountry заглушки.

Теперь я хочу заглушить набор 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;
};

1 Ответ

0 голосов
/ 17 февраля 2012

Этот пост дает ответ:

MolesContext.ExecuteWithoutMoles(() => instance.Country_Id = id);
...