Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 684389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:48:41+00:00 2026-05-14T01:48:41+00:00

I have Created a table like CREATE TABLE [dbo].[tab1]( [Id] [int] NOT NULL, [Name]

  • 0

I have 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 am doing linq to sql query to fetch a data it throw an error “data at the root level is invalid linq”. In further investigation I come to know that the meta column is null in that case. In real it is nullable Do I have to remove the nullable and set some blank root node as default or there is some another way to get rid of the error.


My linq Query which throws error

     var obj1= (from obj in dbContext.tab1s
  where obj.id== 123
select obj).FirstOrDefault<Tab1>();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:48:41+00:00Added an answer on May 14, 2026 at 1:48 am

    Under no circumstances will you receive this error if the value of an XML column is NULL.

    You will, however, receive this error if the field contains malformed XML, as the error suggests.

    SQL Server permits you to do this:

    UPDATE tab1
    SET Meta = 'blah'
    WHERE id = 123
    

    Obviously the string “blah” is invalid XML, but SQL Server still allows it. Linq to SQL does not, because it will try to actually load that XML into an XElement. If you run the query with this value in the column, you will get exactly the same error, Data at the root level is invalid.

    In order to fix this error you need to fix the malformed XML that is present in the database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say my table structure looks something like this: CREATE TABLE [dbo].[table1] ( [id]
Is there a way in SQL Server to create a table with a primary
I would like to have a stored procedure that will update values in a
Given a table: |Name | Hobbies | ----------------------------------- |Joe | Eating,Running,Golf | |Dafydd |
In SQL Server assuming one has columns that need to have the same data
In this sample console app I want to update a row in a table,
I have this query that is optimized for speed (that's why it might look
I try to add a namespace on xml using WITH XMLNAMESPACES. When I execute
I have got hold of a sql server 2008 developer edition and this is
I have a stored procedure in a test instance of a sql server (named

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.