Search code examples
c#oracle-databaselinked-tableslinq2db

How to access an Oracle linked table in Linq2db?


I have a linked table I access like this:

SELECT Id, Name FROM MySchema.Sectors@STATS 

How do I define that in Linq2db?

I tried:

[Table(Schema = "MySchema", Name = "SECTORS@STATS")]
public partial class Sector

but when I try to load it, I get

ORA-00942: table or view does not exist


Solution

  • You have to set Server property:

    [Table(Schema = "MySchema", Name = "SECTORS", Server = "STATS")]
    public partial class Sector
    {
       ...
    }
    

    Also you can do that dynamically when building query:

    var result = db.GetTable<Sector>().ServerName("STATS")
       .ToList();