none
Cross-Database Linq is compling bad SQL RRS feed

  • Question

  • Using a small guide here at the social forums, i found out that i could do Cross-Database Linq by adding a prefix on the attributes in the *DataContext.designer.cs file

    eg.
     [Table(Name="dbo.[205PartsLists]")]

    becomes
     [Table(Name="TecDoc.dbo.[205PartsLists]")]


    which works in some cases !

    The error i get i related to how the Linq "compiler" does its magic ( or lack of )

    take a look at this example:

    {
        SELECT DISTINCT [t0].[DataSupplier], [t0].[GenArtNo]
        FROM [TecDoc].[dbo.[400ArtSearchTree]]] AS [t0]
        INNER JOIN [TecDoc].[dbo.[205PartsLists]]] AS [t1] 
             ON ([t0].[DSArtNo] = [t1].[DSArtNo]) AND ([t0].[DataSupplier] = [t1].[DataSupplier])
    }


    as you will quickly notice, there are WAY too many brackets, even some unneeded ones !

    FROM [TecDoc].[dbo.[400ArtSearchTree]]] AS [t0]

    should of cause be :
    FROM [TecDoc].dbo.[400ArtSearchTree] AS [t0]



    so what am i doing wrong ? - and how do i fix this error ?

    thanks
    Tuesday, September 1, 2009 9:11 AM

Answers

  • solution:

    in the *DataContext.designer.cs file, i had to remove all brackets, then the compiler doesn't fail.

    like this:
     [Table(Name="TecDoc.dbo.205PartsLists")]
    • Marked as answer by Montago Tuesday, September 1, 2009 9:49 AM
    Tuesday, September 1, 2009 9:49 AM