Search code examples
linq-to-sqlcode-generationlinqpad

Is it possible to change LINQPad code generation on XML type?


In SQL Server a table can have a XML column

CREATE TABLE [dbo].[Temp](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [C1] [xml] NULL
)

XML column allows multiple root content, it's legal to put below into xml column

<a>1</a><a>2</a>

When doing query, I got this error,

There are multiple root elements

enter image description here

I think the cause of the error is CLR data type LINQPad/Linq-to-SQL auto-generated.

public XElement C1;

XElement does not allow multiple root content.

Is it possible to intervene the code generation process, so change the data type as string?

public String C1;

btw, the assembly LinqPad generated is at

enter image description here


Solution

  • Yes, use the advanced properties on the SQL Connection dialog to map XML columns to string.

    enter image description here