The LINQ code returns a anonymous type how can I return a strong type of “Customers”?
I am returning a anonymous type as I only want to select certain fields from the entity.
var customer = from c in _entities.Customers
join con
in _entities.Contracts on c.CustomerID equals con.customerID
where con.contractNo == number
select new
{
Surname = c.Surname,
Forename= c.Forename,
Address = c.Address,
Suburb = c.Suburb,
State = c.State,
Postcode = c.PostCode,
PhoneNo = c.PhoneNo
};
Thanks
Either do
to select the customer instances with as-is or
to create new instances of customer with just the properties you are interested in filled out. (provided customer class has a parameterless constructor)