How can i Write list type returning value in Linq with Entity FrameWork?

Posted by programmerist on Stack Overflow See other posts from Stack Overflow or by programmerist
Published on 2010-04-04T12:49:52Z Indexed on 2010/04/04 12:53 UTC
Read the original article Hit count: 445

How can i return List<personel> data type from below procedure. if i press F5 it throw me this error: Error 1 Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Collections.Generic.List'. An explicit conversion exists (are you missing a cast?) C:\Documents and Settings\yusufk\Desktop\EFTestSolutions\WebApplicationTest1\WebApplicationTest1\Default.aspx.cs 101 61 WebApplicationTest1

i think that: i should rearrange or recode "select new {. . . . " ?

  protected List<personel> GetPersonalsData2()
        {
            List<personel> personeller;
            using (FirmaEntities firmactx = new FirmaEntities())
            {
                personeller = (from p in firmactx.Personals select new { p.ID, p.Name, p.SurName });
                return personeller.ToList();
            }
        }
    }

    public class personel
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string SurName { get; set; }
    }

© Stack Overflow or respective owner

Related posts about c#4.0

Related posts about c#