Click here to Skip to main content
15,891,248 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"


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


C#
var getdat=from o in dt.Trade
           join c in cv1.tradevalue on o.id equal c.id 
           select new {o.firstvalue,c.secondvalue};
Posted
Updated 23-May-11 0:12am
v3
Comments
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.

dt.Trade

comes from one data context

cv1.tradevalue

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
C#
[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