I created a table like
CREATE TABLE [dbo].[tab1](
[Id] [int] NOT NULL,
[Name] [varchar](100) NOT NULL,
[Meta] [xml] NULL,
CONSTRAINT [PK_tab1] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
When I do linq for a sql query to retrieve data, it throws an error "data at the root level is invalid linq". In further research, I find out that the meta column in this case is null. In reality, this value is null. Should I remove the nullable value and set the empty node to empty by default or is there another way to get rid of the error.
My Linq query that causes an error
var obj1= (from obj in dbContext.tab1s
where obj.id== 123
select obj).FirstOrDefault<Tab1>();
source
share