LINQ Filtering Select Ouput with IEnumerable<T>

Viewed 162

I have following methods:

Controller:

...
var appmap = Services.GetReqAppMapList(value);
var applist = Services.GetApplicationList(docid, appid, reqid, appmap);
...

Model:

public static IEnumerable<AppMap> GetReqAppMapList(int aiRequestTypeId)
{
    try
    {
        var appmap = new List<AppMap>();
        using (var eties = new eRequestsEntities())
        {
            appmap = (from ram in eties.ReqAppMaps 
                      where ram.IsActive == 1
                      select new AppMap
                      {
                          RequestTypeId = ram.RequestTypeId
                      }).ToList();
            return appmap;
        }
    }
    catch(Exception e)
    {
        throw e;
    }           
}

public static IEnumerable<TicketApplication> GetApplicationList(int aiDocumentTypeId, int aiApplicationTypeId, int aiRequestTypeId, IEnumerable<AppMap> appmap)
{
    try
    {
        var applicationlist = new List<TicketApplication>();                    
        using (var applicationentity = new eRequestsEntities())
        {                 
            applicationlist = (from app in applicationentity.Applications
                               where 1==1   
                                <<<Some Conditions Here???>>>
== && appmap.Contains(app.ApplicationTypeId) ==
                                && app.IsActive == 1
                               select new TicketApplication
                               {
                                   ApplicationId = app.ApplicationId,
                                   Description = app.Description,
                                   DeliveryGroupId = app.DeliveryGroupId,
                                   ApplicationTypeId = app.ApplicationTypeId,
                                   DeliveryTypeId = app.DeliveryTypeId,
                                   DocumentTypeId = app.DocumentTypeId,
                                   SupportGroupId = app.SupportGroupId
                               }).OrderBy(a => a.Description).ToList();

            return applicationlist;
}

And I was thinking how can filter query result of GetApplicationList using the result from GetReqAppMapList

I'm kinda stuck with the fact that I must convert/cast something to the correct type because every time I do a result.Contains (appmap.Contains to be exact), I always get the following error

Error 4 Instance argument: cannot convert from 'System.Collections.Generic.IEnumerable<Test.Models.AppMap>' to 'System.Linq.ParallelQuery<int?>'

2 Answers
Related