Linq Include method not showing up in viewmodel

I have a Silverlight app using mvvm with ria services. I have a textbox on the view that the user puts in a Job Number and clicks find. This find button is using the ICommand in xaml to go here..

public ICommand FindJob
{
    get
    {
        return new DelegateCommand(BeginFindJob, (o) => true);
    }
}

public void BeginFindJob(object o)
{
    if (!IsDesignTime)
    {
        IsLoading = true;
        string jobnum = o.ToString();
        OnPropertyChanged("IsLoading");
        LoadOperation<Job> loadOp = _context.Load<Job>(_context.GetJobsByJobNumQuery(jobnum));
        loadOp.Completed += new EventHandler(loadOp_Completed);
    }
}

It uses the GetJobsByJobNumQuery in my ria service like so..

public IQueryable<Job> GetJobsByJobNum(string JobNum)
{
    var query = ((from j in this.ObjectContext.Jobs
                  where j.JobNumber == JobNum
                  select j) as ObjectQuery<Job>).Include("JobHeadings").Include("JobContracts").Include("JobTags").Include("JobMarket"); 
    return query;
}

Im wanting it to return all the information about the job, so i wrote the query above to include all those relationships. Putting a breakpoint on the linq query and looking at the results, it has exactly what I wont. All the fields, JobHeadings and Contracts are working and bringing back all the bindings to that job. So now I bring that query back in my viewmodel and populate the fields, like so..

void loadOp_Completed(object sender, EventArgs e)
{
    try
    {
        LoadOperation<Job> loadOp = sender as LoadOperation<Job>;
        if (!loadOp.HasError)
        {
            _job = loadOp.Entities.FirstOrDefault<Job>();

            base.IsLoading = false;
            base.ProgressBarVisibility = Visibility.Collapsed;
            base.OnPropertyChanged("IsLoading");
            base.OnPropertyChanged("ProgressBarVisibility");
            base.OnPropertyChanged("CurrentJob");
        }
    }
    catch (Exception ex)
    {
    }
}

My problem is, that no relationship data is coming back. All the basic Job info is coming back from the Job table in my db, but none of the info from the related tables is coming back in my viewmodel. Putting a bp in and looking at _job, which should contain everything, all the relationship tables JobHeading/JobContract say 'Enumeration yielded no results.'

So how is it not making its way back through to the viewmodel? What can i do to get the full query results put into the view/viewmodel so I can make changes?

Answers


Should the Includes not be higher up on the ObjectSet? like this:

public IQueryable<Job> GetJobsByJobNum(string JobNum)
    {
        var query = ((from j in this.ObjectContext.Jobs.Include("JobHeadings").Include("JobContracts").Include("JobTags").Include("JobMarket")
                      where j.JobNumber == JobNum
                      select j) as ObjectQuery<Job>); 
        return query;
    }

Need Your Help

TFS 2010 - Deleting a folder in Visual Studio solution before check-in of changes

visual-studio version-control tfs tfs2010 visual-studio-team-system

We are using TFS 2010 and facing a problem with deleting a folder inside of a solution in Visual Studio.

Max length of send() data param on XMLHttpRequest Post

javascript ajax xmlhttprequest

Is there a documented max to the length of the string data you can use in the send method of an XMLHttpRequest for the major browser implementations?