Dual Table | Linqer

Dual Table

DUAL is a special one row, one column table present by default in all Oracle databases. The table has a single VARCHAR2(1) column called DUMMY, which has a value of 'x '. There is no need to have such a table in MSSQL, but it can be used to convert the  simplest SQL statements to LINQ. For example, the   SELECT 'something ' statement cannot be converted to  LINQ directly, because it does not have the   FROM clause. However, by  having the DUAL table in your schema, you can rewrite your statement to SELECT 'something ' FROM DUAL , which can be converted to LINQ.

Starting with Linqer 4.6, the  DUAL table is implied for SQL statements without the FROM clause.

For example, SELECT 1 UNION SELECT 2 is equivalent to   SELECT 1 FROM DUAL UNION SELECT 2 FROM DUAL . You do not have to rewrite your SQL statement and add the DUAL table manually; Linqer does it automatically.

All you need to do  is create a DUAL table in your database and turn the “DUAL table exists in this Model ”flag on, which can be found in the Edit Connection window.

Here is a script to create a DUAL table.

 

CREATE TABLE [dbo] . [DUAL] (

[DUMMY] [varchar] ( 1 ) NOT NULL,

CONSTRAINT [PK_DUAL] PRIMARY KEY ( [DUMMY] ASC )

)

GO

INSERT INTO DUAL ( [DUMMY] ) VALUES ( 'x ' )

 

Please note that a primary key is required for the DUAL table, in order to use it in the LINQ to Entities Model.