It sounds like the problem here is downstream, i.e. something that is consuming model. In particular, it sounds like it is expecting one N
, not a query of them. So... you might want to add .SingleOrDefault()
, .FirstOrDefault()
, .Single()
or .First()
to your query (depending on what you intended). For example:
var query = from m in db.Customers
orderby m.a descending
select new Get_Complaint_Form_Sub
{
CustomerFullName = m.a,
Email = m.Email_Address,
PhoneNumber = m.Telephone_No
};
var model = query.FirstOrDefault();
As a more general note: an IQueryable<T>
is usually a pending query - it hasn't been executed yet. Most times that you are talking about a model, you'd want to be talking about rigid data; so if you were trying to represent some number of N
, you should probably use .ToList()
or .ToArray()
to evaluate the query and populate a list/array.