I got a good answer to my previous question but it's actually even more complicated:
I need to pass to this stored procedure a list of ints:
ALTER proc [dbo].[Invoice_GetHomePageInvoices] (
@AreaIdList varchar(max)
, @FinancialYearStartDate datetime = null
, @FinancialYearEndDate datetime = null
Here's what I have so far:
public virtual IEnumerable<HomePageInvoice> GetHomePageInvoices(IList<Area> areas, FinancialYearLookup financialYear)
{
var areaIds = areas.Select(x => x.Id).ToList();
//return _db.Database.SqlQuery<HomePageInvoice>(string.Format("EXEC Invoice_GetHomePageInvoices @AreaIdList = '{0}', @FinancialYearStartDate = '{1}', @FinancialYearEndDate = '{2}'", areas.ToString(), financialYear.StartDate.ToString(), financialYear.EndDate.ToString()));
var startDate = new SqlParameter("FinancialYearStartDate", financialYear.StartDate);
var endDate = new SqlParameter("FinancialYearEndDate", financialYear.EndDate);
return _db.Database.SqlQuery<HomePageInvoice>("Invoice_GetHomePageInvoices", startDate, endDate);
}
So the the datetime parameters are sorted. But how would you send the ids to the stored proc given I current have a List<int>
and sql expects @AreaIdList varchar(max)