Если у меня есть пользовательEntity Framework только с одним концом подключен
public class User : BaseEntity
{
public int Id { get; set; }
public AddressId {get;set;}
public Address Address {get; set;}
}
И класс Адрес
public class Address : BaseEntity
{
public int Id { get; set; }
}
Таким образом, только это один к одному только пользователь, имеющий подключение к другой конец.
Как настроить это с помощью свободного API, а также возможно, чтобы мой общий метод SaveOrUpdate учитывал сохранение графиков за один раз?
public static async Task<T> SaveOrUpdateAsync<T>(this GSCMContext context, T updated) where T : BaseEntity
{
if (updated == null)
return null;
if (updated.IsPersisted)
{
T existing = context.Set<T>().Find(updated.Id);
if (existing != null)
{
context.Entry(existing).CurrentValues.SetValues(updated);
await context.SaveChangesAsync();
}
return existing;
}
context.Set<T>().Add(updated);
await context.SaveChangesAsync();
return updated;
}