Microsoft Moles: Rundschreiben Referenzfehler?
-
27-10-2019 - |
Frage
Ich habe die folgenden Einheiten der Entitätsrahmen:
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; }
}
Maulwürfe haben erzeugt Mperson und McOuntry Stubklassen.
Jetzt möchte ich das Set des Country_ID stützen:
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;
};
Lösung
Dieser Beitrag Gibt die Antwort:
MolesContext.ExecuteWithoutMoles(() => instance.Country_Id = id);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow