У меня большой массив, и я хочу разделить на группу массивов объектов по одному атрибуту массива (Date), используя Dapper, это мой метод веб-API.
public IEnumerable<SelectFoodsForFiveDaysVM> FindAllForFiveDays(string Spname,string CustomerID)
{
try
{
DynamicParameters para = new DynamicParameters();
para.Add("@CustomerID", CustomerID);
using (IDbConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString))
{
con.Open();
return con.Query<SelectFoodsForFiveDaysVM>(Spname,para, commandType: CommandType.StoredProcedure).ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
И вот я получил массив
[
{
"ID": 1,
"Price": 140,
"Type": "Rice and Curry - Veg",
"ImagePath": null,
"Date": "2019-03-02T00:00:00",
"MaxNumberOfPackets": 5,
"IsAvailable": true,
"OrderCount": 2,
"DeliveryDate": "2019-03-02T00:00:00",
"FoodTypeID": 1
},
{
"ID": 2,
"Price": 150,
"Type": "Rice and Curry - Egg",
"ImagePath": null,
"Date": "2019-03-02T00:00:00",
"MaxNumberOfPackets": 4,
"IsAvailable": true,
"OrderCount": 1,
"DeliveryDate": "2019-03-02T00:00:00",
"FoodTypeID": 2
},
{
"ID": 3,
"Price": 180,
"Type": "Rice and Curry - Chicken",
"ImagePath": null,
"Date": "2019-03-02T00:00:00",
"MaxNumberOfPackets": 3,
"IsAvailable": true,
"OrderCount": 1,
"DeliveryDate": "2019-03-02T00:00:00",
"FoodTypeID": 3
},
{
"ID": 1,
"Price": 140,
"Type": "Rice and Curry - Veg",
"ImagePath": null,
"Date": "2019-03-03T00:00:00",
"MaxNumberOfPackets": 5,
"IsAvailable": true,
"OrderCount": 0,
"DeliveryDate": "0001-01-01T00:00:00",
"FoodTypeID": 0
}]