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

Aleks G
  • 56,435
  • 29
  • 168
  • 265
Tom S
  • 227
  • 1
  • 6
  • 19

1 Answers1

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>
Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51
  • I'm sorry but I do not understand your response. The tables are on the same server. What does this mean .. as relates to the datacontext? – Tom S Oct 09 '12 at 19:03