I pass a parameter month
and append to a list.
How can I add the list to a SqlQuery
parameter?
Error: No mapping exists from object type System.Collections.Generic.List`1[] to a known managed provider native type.
public ActionResult filterhre(int? month, int? year)
{
List<int> lst = new List<int>();
for (int i = 1; i <= @month; i++)
{
lst.Add(i);
}
ViewBag.location_fraud_year = db.Database.SqlQuery<YearCheck>(@"SELECT fraud_location, count(claim_amount) as counting_claim, sum(claim_amount) as counting_sum FROM testtable
where month(datelocation) in ({0}) and year(datelocation)={1} and fraud_location is not null ",lst, year).ToList();
}
Model:
public class YearCheck
{
public string fraud_location { get; set; }
public int? counting_claim { get; set; }
public decimal? counting_sum { get; set; }
}