M:M Collection Mapping issue with tables across schema namespaces

Thread is closed for posting
2 posts, 0 answers
  1. Tyler
    Tyler avatar
    2 posts
    Member since:
    Oct 2011

    Posted 28 Nov 2011 Link to this post

    Hi guys and gals,

    First of all, apologies if this is in the wrong section, but not quite sure where this would be classified.

    I have an issue where the wrong SQL is being generated from a Many-to-Many collection mapping using the old reverse mapped managed class model.

    A situation schema I have is as follows:

    - Table1K bigint PK NOT NULL
    - etc

    - Table1FK -> NameSpace2.Table1K
    - Table2FK -> dbo.Table2K

    - etc
    - Table2K bigint PK NOT NULL

    They have been setup in the reverse engineering wizard and mapped appropriately as collections on the owner objects, however when I try to access the collections, like as follows

    scope.Extent<Table2>().Where(i => i.Table1s.Count > 0)

    OpenAccess generates something like this:

    Telerik.OpenAccess.Exceptions.DataStoreException: Error executing query: Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'Table1InTable2'.
    Statement(s) could not be prepared.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery()
       at OpenAccessRuntime.Relational.fetch.FetchResultImp.Execute()
    SELECT a.[Table2K] AS COL1 FROM [Table2] a WHERE (SELECT COUNT(*) FROM [Table1InTable2] b WHERE a.[Table2K] = b.[Table2FK]) > 0  Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'Table1InTable2'.

    Another apology for the mock-up and I may have gotten the fakes wrong, but you should get the idea.  I'm having trouble getting OA to include the schema namespace, shouldn't it generate [Namespace2].[Table1InTable2], or is it something I have misconfigured?

    Can anyone help?

    Many thanks in advance,
  2. Tyler
    Tyler avatar
    2 posts
    Member since:
    Oct 2011

    Posted 29 Nov 2011 Link to this post

    I found out how to work around it.

    If anyone is having this issue, please see this link.  http://www.telerik.com/help/openaccess-orm/delimiting-names-of-databases,-schemata,-tables,-columns,-indexes-and-constraints.html

    In short, you need to modify the extension tag in your App.config to include the delimited schema definition aswell as the table name.

Back to Top