Microsoft Moles: ¿Error de referencia circular?
-
27-10-2019 - |
Pregunta
Tengo las siguientes entidades de marco de entidad:
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 ha generado Mero y Municipal clases de stub.
Ahora quiero agitar el conjunto de 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;
};
Solución
Esta publicación da la respuesta:
MolesContext.ExecuteWithoutMoles(() => instance.Country_Id = id);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow