All I need to get all the team members ids so that I can query the contact table.
var teamMembersIds = (from q in _repository.GetQuery<TeamMember>
(t => teamIds.Contains(t.TeamId))
select new { q.ResourceContactId }
)
.ToList();
The problem is that I need to merge it with another anonymous list of ids.
resContactIds.AddRange(teamMembersIds);
I'm getting the following error:
I tried also this:
var resContactIds = new List<int>();
foreach (var _id in teamMembersIds)
{
if(resContactIds.Contains(_id))
{
resContactIds.Add(_id);
}
}
I'm getting the following error: cannot convert from 'AnonymousType#1' to 'int'
With
select new { q.ResourceContactId }
you are selecting an anonymous type, if you want anList<int>
then removenew
and curly braces like::Your other list
resContactIds
is alsoList<int>
, it is not a list of anonymous objects.One more thing to add, you can omit the call
ToList
in your first query sinceAddRange
can acceptIEnumerable<T>