I want to return the delInfo
variable and the data inside it. 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
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
return delInfo;
return should have been
return delInfo;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.