question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disable table name quotes for querying through Oracle DBLINK

See original GitHub issue

TL/DR: Is there a way to disable adding double quotes for table names like MY_TABLE@MY_LINK_NAME when using System.Data.Linq.Mapping attributes?

Hello,

I have a large application migrated from BLToolkit to Linq2db. Everything works great so far except for external tables accessed via Oracle DBLINK. Tables accessed via DBLINK are named like this: MY_TABLE@MY_LINK_NAME:

SELECT ID, NAME FROM MY_TABLE@MY_LINK_NAME

Note that it looks like a table name with special symbols in it, but in fact it isn’t. Database entities are annotated using System.Data.Linq.Mapping attributes:

[Table(Name = "MY_TABLE@MY_LINK_NAME")]
public class MyTable
{
     [Column(Name = "ID")]
     public long ID { get; set; }
}

BLToolkit used to generate table name as is:

SELECT ID, NAME 
FROM MY_TABLE@MY_LINK_NAME

But Linq2db detects a ‘@’ symbol and quotes the table name:

SELECT ID, NAME 
FROM "MY_TABLE@MY_LINK_NAME"

Which is an error because such table doesn’t exist in the database. I don’t seem to be able to find a workaround so far. I found a compatibility option OracleTools.DontEscapeLowercaseIdentifiers that affects table names with lowercase letters, but there is no such an option for the DBLINK @ character.

Environment details

linq2db version: 3.0.0.0 Database Server: Oracle Database Provider: OracleManaged Operating system: Windows .NET Framework: 4.6.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
MaceWinducommented, Dec 24, 2021

Technically, you can also replace SystemDataLinqAttributeReader with own implementation, which split table name into Name/Server parts

1reaction
yalliecommented, Dec 24, 2021

Thanks for the ServerName extension method workaround:

var result = db.GetTable<Sector>().ServerName("STATS")
   .ToList();
Read more comments on GitHub >

github_iconTop Results From Across the Web

Oracle DB quote column names - sql
[TL;DR] The simplest thing to do is to never use double quotes around object names and just let oracle manage the case-sensitivity in...
Read more >
Names for Database Links - Ask TOM - Oracle
Names for Database Links Hi Tom, I only discovered today that in Oracle8 a database link must have the same name as the...
Read more >
Disable using quotation marks around table and column ...
When making queries against an Oracle database the column names and the table names should be surrounded by quotation marks.
Read more >
How to remove DB link username from tablename prefix? (Ora ...
The problem is pl/sql compiler is prefixing the qualified table name with DB link username "fw". Is there a way to tell Oracle...
Read more >
Syntax for Schema Objects and Parts in SQL Statements
This identifier lets you refer to a part of a schema object, such as a column or a partition of a table. Not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found