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

  • Home
  • SEARCH
  • 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 493531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:24:53+00:00 2026-05-13T05:24:53+00:00

I’m having an issue with LINQ2Sql where the value in the database is not

  • 0

I’m having an issue with LINQ2Sql where the value in the database is not getting to my code correctly. Everything is OK except for columns defined as a bit field in the database. In my code after the LINQ query, the value for bit fields is always false. What the heck is going on?

I’ve already tried deleting the table from the SQL desigener and then adding it back in, but that doesn’t make a difference.

I look at the table data in SQL Server Mgmt Studio, and the values for my bit columns are correct: 1 for true, 0 for false. If I edit the table in Mgmt Studio, it has True/False in the right places. If I run my query in LINQ Pad, it returns the correct values. If I go into the debugger and grab the SQL from the LINQ results, I get the correct results when I run that!

Here is my LINQ code …

        var theplan = (from plans in _data.Plans
                       where plans.PlanId.ToString() == sId
                       select plans).FirstOrDefault();

Here are my table definitions …

CREATE TABLE [dbo].[Things](
    [ThingId] [uniqueidentifier] NOT NULL,
    [ValidEnvelope] [bit] NOT NULL,
    [Xmax] [float] NOT NULL,
    [Xmin] [float] NOT NULL,
    [Ymax] [float] NOT NULL,
    [Ymin] [float] NOT NULL,
    [IsValid] [bit] NOT NULL,
 CONSTRAINT [PK_Things] PRIMARY KEY CLUSTERED .... etc.

CREATE TABLE [dbo].[Plans](
    [PlanId] [uniqueidentifier] NOT NULL,
    [Name] [varchar](50) NOT NULL,
    [Created] [datetime] NOT NULL,
    [Modified] [datetime] NOT NULL,
    [ThingId] [uniqueidentifier] NOT NULL,
    [ViewStateId] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_plans] PRIMARY KEY CLUSTERED ... etc.

Not that the Plans.ThingId column points to Things.ThingId as FK. The problem columns are Things.ValidEnvelope and Things.IsValid.

Here is the XML from the dbml file ….

<?xml version="1.0" encoding="utf-8"?>
<Database Name="XXXX" Class="XXXXDbDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
  <Connection Mode="AppSettings" ConnectionString="......" .... />
  <Table Name="dbo.ViewStates" Member="ViewStates">
    <Type Name="ViewState">
      <Column Name="ViewStateId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="Xmax" Type="System.Double" DbType="Float NOT NULL" CanBeNull="false" />
      <Column Name="Xmin" Type="System.Double" DbType="Float NOT NULL" CanBeNull="false" />
      <Column Name="Ymax" Type="System.Double" DbType="Float NOT NULL" CanBeNull="false" />
      <Column Name="Ymin" Type="System.Double" DbType="Float NOT NULL" CanBeNull="false" />
      <Association Name="ViewState_Plan" Member="Plans" ThisKey="ViewStateId" OtherKey="ViewStateId" Type="Plan" />
    </Type>
  </Table>
  <Table Name="dbo.Plans" Member="Plans">
    <Type Name="Plan">
      <Column Name="PlanId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="Name" Type="System.String" DbType="VarChar(50) NOT NULL" CanBeNull="false" />
      <Column Name="Created" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="Modified" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="ThingId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" CanBeNull="false" />
      <Column Name="ViewStateId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" CanBeNull="false" />
      <Association Name="ViewState_Plan" Member="ViewState" ThisKey="ViewStateId" OtherKey="ViewStateId" Type="ViewState" IsForeignKey="true" />
      <Association Name="Thing_Plan" Member="Thing" ThisKey="ThingId" OtherKey="ThingId" Type="Thing" IsForeignKey="true" />
    </Type>
  </Table>
  <Table Name="dbo.Things" Member="Things">
    <Type Name="Thing">
      <Column Name="ThingId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="ValidEnvelope" Type="System.Boolean" DbType="Bit NOT NULL" CanBeNull="false" />
      <Column Name="Xmax" Type="System.Double" DbType="Float NOT NULL" CanBeNull="false" />
      <Column Name="Xmin" Type="System.Double" DbType="Float NOT NULL" CanBeNull="false" />
      <Column Name="Ymax" Type="System.Double" DbType="Float NOT NULL" CanBeNull="false" />
      <Column Name="Ymin" Type="System.Double" DbType="Float NOT NULL" CanBeNull="false" />
      <Column Name="IsValid" Type="System.Boolean" DbType="Bit NOT NULL" CanBeNull="false" />
      <Association Name="Thing_Plan" Member="Plans" ThisKey="ThingId" OtherKey="ThingId" Type="Plan" />
    </Type>
  </Table>
</Database>
  • 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-13T05:24:53+00:00Added an answer on May 13, 2026 at 5:24 am

    Found the problem in another part of the code. Stupid mistake.

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

Sidebar

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.