Click here to Skip to main content
15,742,357 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using two data context and retrieving values i get the following error "the query contains reference to items in a different data context"

dbWebEnrollDataContext dt1 = new dbWebEnrollDataContext();
CommissionsV2DataContext cv1 = new CommissionsV2DataContext();

var getdat=from o in dt.Trade
           join c in cv1.tradevalue on equal 
           select new {o.firstvalue,c.secondvalue};
Updated 23-May-11 0:12am
Wayne Gaylard 23-May-11 5:51am    
Can you post the code so we can see what you are trying to achieve ?
OriginalGriff 23-May-11 6:08am    
Without the Linq query, we have to hack into your PC and find it ourselves. And you wouldn't want that, now would you?
Use the "Improve question" widget to add the query to your question.

AFAIK you cannot use 2 separate data contexts within a single query.


comes from one data context


comes from another

So you need to create one data context that includes both tables. You should then be able to achieve what you are after.
Share this answer
The solution to this problem is

The class which creates the table add the <databasename>.<dbo>.<tablename>
as shown below
[Table(Name = "Storedata.dbo.Demo")]
   public partial class Demo : INotifyPropertyChanging, INotifyPropertyChanged
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900