[英]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.