I want to return my result as array list. My code looks like this:
public Person Get(string doctorCode)
{
using (PharmaOCEAN_LTEntities entities = new PharmaOCEAN_LTEntities())
{
return entities.Person.FirstOrDefault(e => e.DoctorLicenseNumber == doctorCode);
}
}
Some guy informed me that selected (all) result will be an array, so I tried this way, but im getting an error with select statement:
public IList<Person> Get(string doctorCode)
{
using (PharmaOCEAN_LTEntities entities = new PharmaOCEAN_LTEntities())
{
return entities.Person.Select<Person>(e => e.DoctorLicenseNumber == doctorCode);
}
}
any opinions?
Yeah sure you can! As a array:
public Person[] Get(string doctorCode)
{
using (PharmaOCEAN_LTEntities entities = new PharmaOCEAN_LTEntities())
{
return entities.Person.Where(e => e.DoctorLicenseNumber == doctorCode).ToArray();
}
}
As a list:
public IEnumerable<Person> Get(string doctorCode)
{
using (PharmaOCEAN_LTEntities entities = new PharmaOCEAN_LTEntities())
{
return entities.Person.Where(e => e.DoctorLicenseNumber == doctorCode).ToList();
}
}
not sure if it compiles, but you get the message :)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments