为什么我会"the best overloaded List<DelegationInformation> add method for the collection initialize



我想返回delInfo变量及其内部的数据。但我不明白它到底出了什么问题?

我得到错误

集合初始值设定项的最佳重载List add方法具有一些无效参数

这是我的代码:

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
};
}
}

只需返回delInfo,因为它已经列出

return delInfo;

返回应该是

return delInfo;

相关内容

最新更新