简体   繁体   English

为什么我会得到“最好的重载列表”<delegationinformation> 集合初始值设定项的 add 方法有一些无效参数”</delegationinformation>

[英]Why am I getting “the best overloaded List<DelegationInformation> add method for the collection initializer has some invalid arguments”

I want to return the delInfo variable and the data inside it.我想返回delInfo变量和其中的数据。 But I can't understand what exactly going wrong with it?但我不明白它到底出了什么问题?

I am getting the error我收到错误

The best overloaded List add method for the collection initializer has some invalid arguments集合初始化器的最佳重载列表添加方法有一些无效的 arguments

Here's my code:这是我的代码:

public List<DelegationInformation> GetDelegations(string profileUid, List<int> userPrivilegeIds)
{
    using (var context = GetDBContext())
    {
        var delInfo =
            (
                from delegation in context.vw_Delegations
                where delegation.Delegator == profileUid && userPrivilegeIds.Contains(delegation.AccessPrivilegeID)
                select new DelegationInformation()
                {
                    id = delegation.DelegationID,
                    DelegationId = delegation.DelegationID,
                    AccessPrivilegeId = delegation.AccessPrivilegeID,
                    AccessPrivilegeKey = delegation.AccessPrivilegeKey,
                    AccessPrivilegeName = delegation.AccessPrivilegeName,
                    Enabled = delegation.Status,
                    IsPermanent = delegation.isPermanent.HasValue ? delegation.isPermanent.Value : false,
                    Delegatee = delegation.Delegatee,
                    DelegateeFirstName = delegation.DelegateeFirstName,
                    DelegateeLastName = delegation.DelegateeLastName,
                    Delegator = delegation.Delegator,
                    DelegatorFirstName = delegation.DelegatorFirstName,
                    DelegatorLastName = delegation.DelegatorLastName,
                    StartDate = delegation.StartDate,
                    EndDate = delegation.EndDate,
                    ChangedBy = delegation.ChangedBy,
                    ChangedOn = delegation.ChangedOn,
                }
            ).ToList();

        foreach (var item in delInfo)
        {
            item.DelegateeFullName = ARMCommon.GetProfileDisplayName(item.Delegatee);
            item.DelegatorFullName = ARMCommon.GetProfileDisplayName(item.Delegator);
        }

        return new List<DelegationInformation>
        {
           delInfo
        };
    }
}

Just return delInfo as it is already list只需返回 delInfo,因为它已经列出

return delInfo;
                    

return should have been回报应该是

return delInfo;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “集合初始化程序的最佳重载Add方法&#39;System.Collections.Generic.List.Add(System.Guid)&#39;具有一些无效的参数” - “The best overloaded Add method 'System.Collections.Generic.List.Add(System.Guid)' for the collection initializer has some invalid arguments” CS1950 最好的重载add方法字典<string,func<string> ) 对于集合初始值设定项有一些无效的 arguments </string,func<string> - CS1950 The best overloaded add method Dictionary<string,Func<string>) for the collection initializer has some invalid arguments List的最佳重载方法匹配 <T> .Add(T)有一些无效的参数 - the best overloaded method match for List<T>.Add(T) has some Invalid arguments 获得CS1502:最适合的重载方法 <some_method> 有一些无效的论点 - Getting CS1502: The best overloaded method match for <some_method> has some invalid arguments System.Collection ..的最佳重载方法匹配具有一些无效的参数 - The best overloaded method match for System.Collection.. has some invalid arguments 最好的重载方法匹配...具有一些无效的参数 - The best overloaded method match for… has some invalid arguments 最好的重载方法有一些无效参数和无法转换类型 - The best overloaded Method has some invalid arguments and Cannot convert type XXX的最佳重载方法匹配具有一些无效的参数 - The best overloaded method match for XXX has some invalid arguments 最佳重载方法匹配是否具有一些无效参数? - The best overloaded method match for has some invalid arguments? 最佳的重载方法匹配在Unity 5中具有一些无效的参数 - The best overloaded method match has some invalid arguments in Unity 5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM