I'm trying to query a db set, but I can't seem to access the data when I get the results. Here is the code I've tried.
Query #1:
public List<CustomerMain> testing()
{
var context = new CustomerEntities();
var query = context.CustomerMains
.Where(p=> p.FirstName == "Thor")
.Select(p => new CustomerMain {FirstName=p.FirstName,LastName =p.LastName}).ToList();
return query;
}
Query #2:
public IQueryable<CustomerMain> testing()
{
var context = new CustomerEntities();
var query = context.CustomerMains
.Where(p=> p.FirstName == "Thor")
.Select(p => new CustomerMain {FirstName=p.FirstName,LastName =p.LastName});
return query;
}
CustomerMain
is my DbSet
, If I run either of those and assign the method to a var variable, it gives me no options to grab the FirstName
or LastName
from the variable. I found I can do it if I convert it to a CustomerMain
, but shouldn't the return query be in a CustomerMain
type already?