.Net core 3.1
This is my tables
I am not allowed to add any foreign keys or new relation into them. I made a stored procedure that joins other 3 tables to Ordering_Policy table.
create procedure spOrderingPolicy
as
select op.Id, op.Tyre_Grade, op.Tyre_Group, tb.Tyre_Brand, ss.Status, tc.Cosmetic
from [dbo].[Ordering_Policy] as op
left join [dbo].[Tyre_Brand] as tb
on op.Tyre_Brand_Id = tb.Id
left join [dbo].[Shearography_Status] as ss
on op.Shearography_Id = ss.Id
left join [dbo].[Tyre_Cosmetic] as tc
on op.Cosmetic_Id = tc.Id
go
The result result is as expected:
So I tried to call the procedure:
public IEnumerable<OrderingPolicy> GetOrder()
{
using (Ordering_PolicyContext context = new Ordering_PolicyContext())
{
var order = context.OrderingPolicies.FromSqlRaw<OrderingPolicy>("spOrderingPolicy").ToList();
return order;
}
}
But it ignores anything not in the Ordering_Policy: result
How do I call the procedure and displays all the data like in the query?
Edit: This is the class for OrderingPolicy
namespace Ordering_Policy.Models
{
public partial class OrderingPolicy
{
public int Id { get; set; }
public string TyreGrade { get; set; }
public int? TyreGroup { get; set; }
public int? ShearographyId { get; set; }
public string CasingLife { get; set; }
public string Variance { get; set; }
public string ColorCode { get; set; }
public string Injury { get; set; }
public int? MaxCrownPatch { get; set; }
public int? MaxShoulder { get; set; }
public int? Age { get; set; }
public int? CosmeticId { get; set; }
public int? TyreBrandId { get; set; }
}
}