1

I'd like my Linq query to create an additional column in the results on the fly. In this case the column is a Class object I created that will contain image info. I was wondering what the right way is of doing this:

var validPics = (from x in db.picsVotesTagsJs let picObj = new CarShowImages(x.picname) where x.enabled == 1 select x).Take(25);
var myArray = validPicSummaries.ToArray();

Line 2 gerenates the error:

Only parameterless constructors and initializers are supported in LINQ to Entities.

This is my first time using the Let clause. My queries are usually pretty simple.

4

1 回答 1

1

创建无参数构造函数并使用一些公共属性(例如PicName)为您的CarShowImages对象设置图片名称:

var validPics = (from x in db.picsVotesTagsJs
                 where x.enabled == 1
                 select new CarShowImages { PicName = x.picname }).Take(25);
var myArray = validPics.ToArray();
于 2013-04-17T13:00:13.990 回答