Код: Выделить всё
public class ServiceEquipment
{
[ForeignKey("Service")]
public long ServiceRef { get; set; }
public Service Service { get; set; }
[ForeignKey("Equipment")]
public long EquipmentRef { get; set; }
public Equipment Equipment { get; set; }
}
Код: Выделить всё
static IEdmModel GetEdmModel()
{
ODataConventionModelBuilder builder = new();
.
.
.
builder.EntitySet("ServiceEquipments");
return builder.GetEdmModel();
}
Код: Выделить всё
public class ServiceEquipmentsController : ODataController
{
private readonly SqlServerContext _sqlServerContext;
public ServiceEquipmentsController(SqlServerContext sqlServerContext)
{
_sqlServerContext = sqlServerContext;
}
[HttpGet]
[EnableQuery]
public IQueryable Get()
{
IQueryable srEqList = _sqlServerContext.ServiceEquipment.AsQueryable();
return srEqList;
}
}
System.InvalidOperationException: 'Набор сущностей 'ServiceEquipments'
основан на типе 'ArtaNG_API.Models.ServiceEquipment', который не имеет ключи
определены.'
Есть ли способ использовать OData в этой таблице?
Подробнее здесь: https://stackoverflow.com/questions/757 ... -a-primary
Мобильная версия