Hello all i have a small issue with Linqpad with a poorly setup Database
Firstly i have a database where the creator has tables with column named the same as table which he is using as an enabled field.
In Addition to this these tables have the columns Content and Value.
After experimenting with this if the table has a column named the same as the Table it renames the column to Content and then Value if it has a column name similarly named.
if i then try to query (below) i loose the column with the same column name as the table. Does anyone know of any method to get around this. as it makes linqpad use impossible as this is prominent over all the database tables i am currently using?
Example below
If i have
CREATE TABLE [dbo].[TestTable](
[TestTableID] [int] NOT NULL,
[TestTable] [varchar](max) NULL,
[Content] [varchar](max) NULL,
[Value] [varchar](max) NULL
)
As you can see i'm missing the column
This got me going for the better part of an hour now, but I think I found a working solution for you.
the problem is the Linq-To-Sql provider in Linqpad itself. If you open up Visual Studio and create a context class based on your database, you will notice the column TestTable
gets renamed to TestTable1
.
So what I have done to take advantage of this, is created a new project of type "class library" - target Framework 4.0.
In this I added a new Linq-to-Sql class and dragged the TestTable into it.
Go into your class1.cs and insert: (I don't know if this is neccessary)
//I named my context L2S. Replace accordingly
public L2SDataContext context = new L2SDataContext();
Compile
Add a new connection to Linqpad using a typed context!
Connect to your server