Linqpad may have a column with the same name as the table name

Hi everyone, I have a little problem with Linqpad with a badly configured database

Firstly, I have a database where the creator has tables with a column with a name similar to the table that he uses as a support field.

In addition to this, these tables have Content and Value columns.

After experimenting with this, if the table has a column with a name similar to the table, it renames the column to Content, and then Value if it has a column name similarly named.

if I try to execute the query (below), I will lose the column with the same column name as the table. Does anyone know of a method to get around this. as it makes using linqpad impossible, as it is noticeable in all the database tables that i'm currently using?

Example below

if I have

Testtable layout

   CREATE TABLE [dbo].[TestTable](
    [TestTableID] [int] NOT NULL,
    [TestTable] [varchar](max) NULL,
    [Content] [varchar](max) NULL,
    [Value] [varchar](max) NULL
) 

enter image description here

As you can see im is missing

+3
source share
2 answers

It made me go for most of the hour, but I think I found a working solution for you.

the problem is the Linq-To-Sql provider in Linqpad itself. If you open Visual Studio and create a context class based on your database, you will notice that the column is TestTablerenamed to TestTable1.

, , , " " - target Framework 4.0.

  • Linq-to-Sql TestTable. enter image description here

  • 1.cs : ( , )

    //I named my context L2S. Replace accordingly

    public L2SDataContext context = new L2SDataContext();

  • Compile

  • Linqpad, ! enter image description here

  • Query! the result
+1

, "foo" "foo", "content" linqpad.

"" , , ( , "" ).

, ( , , ) , .

0

All Articles