Link to home
Start Free TrialLog in
Avatar of petra schulz
petra schulz

asked on

Wpf-Project Update a LinQ -Join

This is the best option I found,
https://stackoverflow.com/questions/10538395/modifying-linq-results

but cant figure this line
var orderlist = from x in cqsDC.MasterQuoteRecs

Open in new window


First intention was, MasterQuoteRecs its just a mistake, has to be MasterQuote, like the class name, but of course it wasnt.

So, I have no Idea how that comes together?
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

The line in question, var orderlist = from x in cqsDC.MasterQuoteRecs, is as follows

cqsDC is the data context that represents the database in code and  MasterQuoteRecs is the variable to the table in the database and it is MasterQuoteRecs and not MasterQuote. The x represents a individual row of the table. The class MasterQuote is being used to return a  concrete data type  instead of returning an anonymous type.

Please post the data table schema of the database tables that you will be using in the query as well as what you want as the results of the query.
Avatar of petra schulz
petra schulz

ASKER

well, lets say I have this entity model,
  using (NorthwindEntities context = new NorthwindEntities())
So, what is it I have to do, to continue like : "context."  , after that point "MasterQuoteRecs" is within the list
Hi petra;                                                                                                  
                                                                                                           
So here is a code snippet that will work with Northwind database and display the results in a DataGridView.
// The city of the customers to be returned from the query
string cityOfCustomer = "New York";

using (NorthwindEntities context = new NorthwindEntities())
{
    // The variable results will contain a collection of customers
    // who meet the where clause
    var results = (from c in context.Customers
                   where c.City == cityOfCustomer
                   select c
                  ).ToList();

    // Display the results in a DataGridView
    dataGridView1.DataSource = results;
}

Open in new window

- writing "context"
- set a "."
- a dropdownlist opens
- but doesnt have "MasterQuoteRecs"

you have it?
Well the first thing you need to verify is that the MasterQuoteRecs database table is in the DbContext.. if it is not you need to add it to the model. Make sure that you re-compile the project when ever you update the model so that it gets reflected in code.
maybe you like to correct something, within your last post
Like what?
like:
- subject is about "Update a LinQ -Join" a JOIN
- the link, i post here, leads to stackoverflow, but at least it isnt an example to update a linq-join-string, i just see it right now.

Is what happend if smart ones have to think about : how to make the stupid ones not to missuse my question.
- how to make them stick to the real question, so they dont talk bullshit, and I have to stop them, which they take as an offence
- and so one

But its not refering to you.
So, lets get back to the real subject.
Any Idea how to update a LinQ join like:
 
var query = from cat in context.Categories
                            join prod in context.Products
                            on cat.CategoryID equals prod.CategoryID
                            orderby cat.CategoryName
                            select cat;                  
                this.dataGrid1.ItemsSource = query.ToList();

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you are the smartest person I ever met, and I mean it
Thanks, If that answered your question please don't forget to close the thread by selecting the solution. Have a great day.
Provided the solution