gpt4 book ai didi

c# - LINQ to Entities 不支持 LINQ 表达式节点类型 'NewArrayBounds'

转载 作者:太空宇宙 更新时间:2023-11-03 12:28:06 24 4
gpt4 key购买 nike

 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();

在这里,Roles 是一个整数数组,但它不允许我分配一个空数组 零。 帮助将不胜感激。

最佳答案

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

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();

关于c# - LINQ to Entities 不支持 LINQ 表达式节点类型 'NewArrayBounds',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43856228/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com