0

I have a query, may be poorly written since I'm not sure about this at all, that tries to join (3) tables over (2) contexts, since we have split the database into different logical areas. I get the following error message "The query contains references to items defined on a different data context."

 Dim _db As DBML.XDataContext _db = New DBML.XDataContext(ConfigurationManager.ConnectionStrings("TempConnectionString").ToString) Dim _db1 As DBML.YDataContext _db1 = New DBML.YDataContext(ConfigurationManager.ConnectionStrings("TempConnectionString").ToString) Dim FAL = (From r In _db.SendingD _ Join e In _db1.Entity On r.USR_FA Equals e.FANo _ And r.USR_HomeD Equals e.OANo _ Join b In _db1.Buildings On e.OBNo Equals b.BuildNo Where r.USR_FA = FA _ Select b.BuildNo, b.BuildName).ToList() For Each ab In FAL list.Add(New ListItem(ab.BuildNo & "-" & ab.BuildName, ab.BuildNo)) Next Return list 

What would I need to do to join the tables to get the results. SendingD is related to Entity on USR_FA = FAno and USR_HomeD = OANo and then Entity is related to Buildings on OBNo = BuildNo

1

1 Answer 1

1

If that's the same server then we prefixed the table name with:

<DatabaseName>.<SchemaName>.<YourTableName> 

if they are on a linked server then you have to prefix it with the server name

<ServerName>.<DatabaseName>.<SchemaName>.<YourTableName> 
Sign up to request clarification or add additional context in comments.

1 Comment

I'm sorry but I do not understand your response. The tables are on the same server. What does this mean <DatabaseName>.<SchemaName>.<YourTableName> as relates to the datacontext?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.