I have a problem with converting linq result to object.
I have a class called Plant
and a database which contains information about it (for example name, latin name, habitats etc).
I want to create a new object from executed query and send it to another part of application. So I'm messing with this code:
using (DataClassesDataContext dc = new DataClassesDataContext())
{
var sPlant = (from p in dc.Plants where p.Name == plantName select new Plant
{
Name = p.Name,
LatinName = p.LatinName,
Habitat = p.Habitat,
LeafHarvesting = p.LeafHarvesting,
FlowerHarvesting = p.FlowerHarvesting,
FruitHarvesting = p.FruitHarvesting,
RootHarvesting = p.RootHarvesting,
Morphology = p.Morphology,
Pharmacology = p.Pharmacology,
Img = p.Img,
GPSCoordinates = p.GPSCoordinates
}
);
But it doesn't convert result to a new Plant
object.