c# - convert query to object using LINQ TO SQL -


i'm working linq sql in c# connect sql database

and have table on database called person holds information persons , have following fields person_id, first_name,last_name,email,password

i have following query returns 1 row if there matched :

linqdatacontext data = new linqdatacontext();             var query = in data.persons                         a.email == "any email string"                         select a; 

my question how convert query instance of equivalent class define :

class person {     public int person_id;     public string first_name;     public string last_name;     public string e_mail;     public string password;     public person() { } }  

like this:

person query = (from in data.persons             a.email == "any email string"             select new person { person_id = a.id, , on }).firstordefault(); 

Comments