I am migrating a .Net Framework project to .Net Core. In my .Net Framework code I call a stored procedure and it returns a list<int> in a datatable:
DataTable dt = new DLDistinctWarehousePackingOperation().CreatePacking(packingId, userId,
previousOrderId, totalAwaitingOrdersAllowed);
List<int> items = new List<int>();
foreach (DataRow dr in dt.Rows)
{
items.Add(int.Parse(dr["orderid"].ToString()));
}
return items;
This is the .Net Core code I have come up with until now:
List<int> items = dbContext.FromSql("CreatePacking")
.Select(t => new List<int> { t.OrderId.Value })
.ToList();
But it doesn't work. The problem is that an object needs to follow dbContext - like this dbContext.MyObject.FromSql - but in this case it should just be a List of ints - the stored procedure is not connected to any specific object. And how can I return a List<int>? or perhaps it has to be converted into a class? Thanks in advance.
