This is a migrated thread and some comments may be shown as answers.

M:M Collection Mapping issue with tables across schema namespaces

1 Answer 53 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tyler
Top achievements
Rank 1
Tyler asked on 29 Nov 2011, 02:37 AM
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:

Namespace2.Table1
- Table1K bigint PK NOT NULL
- etc

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

dbo.Table2
- 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()
SQL:
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,
Tyler.

1 Answer, 1 is accepted

Sort by
0
Tyler
Top achievements
Rank 1
answered on 29 Nov 2011, 06:27 AM
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.

Cheers!
Tags
Databases and Data Types
Asked by
Tyler
Top achievements
Rank 1
Answers by
Tyler
Top achievements
Rank 1
Share this question
or