Build string method using complex type Entity Framework ASP.NET C#

前端 未结 2 1863
梦毁少年i
梦毁少年i 2021-01-27 06:07

I had to use Entity Framework to equip an advanced search to my website application.

The model is generated from the database and has own entities but has some complex s

2条回答
  •  情深已故
    2021-01-27 06:23

    This is your problem, read up on c# anonymous types

    q => new
        {
            q.cFName,
            q.cLName,
            q.cSex,
            q.aId,
            q.cId,
            q.stars
       });
    

    Remove new, and if needed create a new type to hold this, adding back in new with

    new MyNewType {.. };
    

    THen use this type in your method

提交回复
热议问题