Lightswitch Query Throws Unsuported Exception

I have the following piece of code to get a list of ISE jobs that are not already used for a Job name:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Security.Server;
namespace LightSwitchApplication
{
    public partial class DashboardStatsDataService
    {
        partial void ISEJobsNotInJobs_PreprocessQuery(ref IQueryable<ISEJob> query)
        {
            var jobs = this.DataWorkspace.Dashboard.Jobs.GetQuery().Execute();

            query = query.Where(iseJob => !jobs.Any(job => job.Name == iseJob.JobName));
        }
    }
}

Open in new window


The Job and ISEJob table are not related in any way in the Lightswitch application.

When the query runs it throws:
Not Implemented Inner exception message: The expression is not supported. Expression: LightSwitchApplication.ISEJob[].Where(iseJob => Not(value(LightSwitchApplication.DashboardStatsDataService+<>c__DisplayClass0).jobs.Any(job => (job.Name == iseJob.JobName)))) Inner exception message: The expression is not supported. Expression: iseJob => Not(value(LightSwitchApplication.DashboardStatsDataService+<>c__DisplayClass0).jobs.Any(job => (job.Name == iseJob.JobName))) Inner exception message: The expression is not supported. Expression: iseJob => Not(value(LightSwitchApplication.DashboardStatsDataService+<>c__DisplayClass0).jobs.Any(job => (job.Name == iseJob.JobName))) Inner exception message: The expression is not supported. Expression: Not(value(LightSwitchApplication.DashboardStatsDataService+<>c__DisplayClass0).jobs.Any(job => (job.Name == iseJob.JobName))) Inner exception message: The expression is not supported. Expression: value(LightSwitchApplication.DashboardStatsDataService+<>c__DisplayClass0).jobs.Any(job => (job.Name == iseJob.JobName)) Inner exception message: Expression of type 'System.Collections.Generic.IEnumerable`1[LightSwitchApplication.Job]' cannot be used for parameter of type 'System.Collections.Generic.IEnumerable`1[LightSwitchApplication.Implementation.Job]' of method 'Boolean Any[Job](System.Collections.Generic.IEnumerable`1[LightSwitchApplication.Implementation.Job], System.Func`2[LightSwitchApplication.Implementation.Job,System.Boolean])'

Open in new window


I am not sure exactly what the query processor does not like about my LINQ to IQueryable code.  I have done something similar in the past, but with related data.
VordiemApplication ProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VordiemApplication ProgrammerAuthor Commented:
I think I may have gotten this...
 
IQueryable<String> jobNames = this.DataWorkspace.Dashboard.Jobs.Select(x => x.Name).Execute().AsQueryable<String>();
query = query.Where(iseJob => !jobNames.Contains(iseJob.JobName));

Open in new window


I am pretty sure that the jobNames runs on the server side from the Linq statement construction. Should It perform the same over a large dataset?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lokesh B RDeveloperCommented:
Hi,

try this

var jobNames = from p in this.DataWorkspace.Dashboard.Jobs()
                            where !jobNames.Contains(o.Name)
                            select o.Name;

Open in new window

VordiemApplication ProgrammerAuthor Commented:
The code supplied by the expert contained coding errors and was a less elegant version of the solution I discovered on my own.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.