LINQ to Entities不支持LINQ表达式节点类型'NewArrayBounds' [英] The LINQ expression node type 'NewArrayBounds' is not supported in LINQ to Entities

查看:64
本文介绍了LINQ to Entities不支持LINQ表达式节点类型'NewArrayBounds'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 select new ProviderMeta
            {
                LoginId = user.LoginId,
                AgencyId = user.AgencyId,
                Application = user.Application,
                UserId = user.UserId,
                Name = agencySnapshot.Name,
                Roles = new int[0],
                Cluster = app.ClusterId ?? 0,
                Created = app.Created,
                TitleType = user.TitleType,
                Feature = (foundFeature == null ? 0 : foundFeature.Feature)
            }).ToList();

在这里,角色"是一个整数数组,但不允许我分配一个空数组 与零. 帮助将不胜感激.

Here, Roles is an integer array but it is not letting me assign an empty array with zero. Help would be appreciated.

推荐答案

在您的类的空构造函数中初始化数组:

Initialize the array in an empty constructor of your class:

public class ProviderMeta
{
    //...
   public ProviderMeta()
   {
     Roles = new int[]{0};
   }
}

并将其从投影中删除

 select new ProviderMeta
        {
            LoginId = user.LoginId,
            AgencyId = user.AgencyId,
            Application = user.Application,
            UserId = user.UserId,
            Name = agencySnapshot.Name,
            //Roles = new int[0], remove this line
            Cluster = app.ClusterId ?? 0,
            Created = app.Created,
            TitleType = user.TitleType,
            Feature = (foundFeature == null ? 0 : foundFeature.Feature)
        }).ToList();

这篇关于LINQ to Entities不支持LINQ表达式节点类型'NewArrayBounds'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆