c# - The specified type member 'Title' is not supported in LINQ to Entities -


i got error when using title property in linq entity:

the specified type member 'title' not supported in linq entities. initializers, entity members, , entity navigation properties supported.

my query is:

        var db = faraworkspaceentity.getentity();          var query = item in db.projectmanagers                     item.projectid == projectid                     select new userlistitem                     {                         id = item.userid,                         title = item.user.title // here error                     };          return query.tolist();        public class user : identityuser<string, userlogin, userrole, userclaim>     {         [required]         [display(name = "نام")]         [stringlength(50)]         public string firstname { get; set; }          [required]         [display(name = "نام خانوادگی")]         [stringlength(50)]         public string lastname { get; set; }          public string title         {             { return this.firstname + " " + this.lastname; }         }     } 

title property in entity. in table there not such column. entity framework can not convert code sql. so, must change code as:

  var query = item in db.projectmanagers               item.projectid == projectid               select new userlistitem               {                    id = item.userid,                    title = item.user.firstname + " " + item.user.lastname;               }; 

but, suggest select firstname , lastname, , when want value of title getter accessor work:

  var query = item in db.projectmanagers               item.projectid == projectid               select new userlistitem               {                    id = item.userid,                    firstname = item.user.firstname                    lastname =  item.user.lastname;               }; 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -