title: LINQ Comparison error
body: <p>I am getting a comparison error message when trying to update a record using LINQ.</p>
  
  <pre><code>var tools = from tl in MVCWebsite.MvcApplication.DataContext.tblTools
                                                 where tl.pk_fk_Environment == model.Environment
                                                 &amp;&amp; tl.pk_fk_Classification == model.Classification
                                                 &amp;&amp; tl.pk_ToolNumber == model.ToolNumber
                                                 select tl;
          Models.Database.tblTool updatingTool = tools.First();
          //try
          //{
  
          if (createPerson(model.ToolEngineer, true) != null)
              updatingTool.fk_Engineer = model.ToolEngineer;
          else
              updatingTool.fk_Engineer = null;
  
          updatingTool.fk_BuiltBy = model.ToolBuiltBy;
  
          if (createPerson(model.ToolBuiltBy, true) != null)
              updatingTool.fk_BuiltBy = model.ToolBuiltBy;
          else
              updatingTool.fk_BuiltBy = null;
          if (createPerson(model.ToolDesignedBy, true) != null)
              updatingTool.fk_Designer = model.ToolDesignedBy;
          else
              updatingTool.fk_Designer = null;
          updatingTool.DateOfBuild = model.DateOfBuild;
          updatingTool.Machine_Name_Primary = model.ToolPrimaryMachineName;
          updatingTool.Machine_Description_Primary = model.ToolPrimaryMachineDescription;
          updatingTool.Machine_Name_Secondary = model.ToolSecondaryMachineName;
          updatingTool.Machine_Description_Secondary = model.ToolSecondaryMachineDescription;
          updatingTool.MERNumber = model.MERNumber;
          updatingTool.AssetNumber = model.AssetNumber;
          updatingTool.Additional_Cavities = model.AdditionalFields.Cavities;
          updatingTool.Additional_Gate = model.AdditionalFields.TypeOfGate;
          updatingTool.Additional_Shrinkage = model.AdditionalFields.Shrinkage;
          updatingTool.Additional_DieClearance = model.AdditionalFields.DieClearance;
          updatingTool.Additional_Field1 = model.AdditionalFields.Additional1;
          updatingTool.Additional_Field2 = model.AdditionalFields.Additional2;
          updatingTool.Additional_Field3 = model.AdditionalFields.Additional3;
          updatingTool.Additional_Field4 = model.AdditionalFields.Additional4;
          updatingTool.Additional_OtherInformation = model.AdditionalFields.OtherInformation;
  </code></pre>
  
  <p>(Below is the create user function)</p>
  
  <pre><code>private Models.Database.tblPerson createPerson(string user)
      {
          if (user == null || user == "")
              return null;
          var people = from p in MVCWebsite.MvcApplication.DataContext.tblPersons
                       where p.pk_PersonID == user
                       select p;
          if (people.Count() == 1)
          {
              return people.First();
          }
          else
          {
              Models.UserInformation ui;
              ui = MVCWebsite.MvcApplication.DisplayUser(user);
              if (!ui.Exists)
                  return null;
              tblPerson person = new tblPerson()
              {
                  pk_PersonID = user,
                  FirstName = ui.GivenName,
                  LastName = ui.Surname,
                  Email = ui.EmailAddress
              };
              return person;
          }
      }
  </code></pre>
  
  <p>I am not bothered about if my code is clean or not at the moment, I am just getting this error and it is starting to annoy me.</p>
  
  <p>Here is the Main Table Scripted as a Create (So you can see the field settings:</p>
  
  <pre><code>CREATE TABLE [dbo].[tblTool](
      [pk_fk_Environment] [varchar](2) COLLATE Latin1_General_CI_AS NOT NULL,
      [pk_fk_Classification] [varchar](3) COLLATE Latin1_General_CI_AS NOT NULL,
      [pk_fk_Style] [varchar](4) COLLATE Latin1_General_CI_AS NULL,
      [pk_ToolNumber] [int] NOT NULL,
      [DateOfBuild] [datetime] NULL,
      [fk_Engineer] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [fk_Designer] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [fk_BuiltBy] [varchar](20) COLLATE Latin1_General_CI_AS NULL,
      [MERNumber] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [AssetNumber] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [fk_Material] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [fk_LocationCompany] [varchar](20) COLLATE Latin1_General_CI_AS NULL,
      [fk_LocationCountry] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [fk_LocationRegion] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [fk_Status] [varchar](10) COLLATE Latin1_General_CI_AS NULL,
      [Machine_Name_Primary] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [Machine_Description_Primary] [text] COLLATE Latin1_General_CI_AS NULL,
      [Machine_Name_Secondary] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [Machine_Description_Secondary] [text] COLLATE Latin1_General_CI_AS NULL,
      [OldToolID] [varchar](100) COLLATE Latin1_General_CI_AS NULL,
      [Additional_Cavities] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [Additional_Gate] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [Additional_Shrinkage] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [Additional_DieClearance] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [Additional_Field1] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [Additional_Field2] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [Additional_Field3] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [Additional_Field4] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
      [Additional_OtherInformation] [text] COLLATE Latin1_General_CI_AS NULL,
   CONSTRAINT [PK_tblTool] PRIMARY KEY CLUSTERED 
  (
      [pk_fk_Environment] ASC,
      [pk_fk_Classification] ASC,
      [pk_ToolNumber] ASC
  )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
  ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  </code></pre>
  
  <p>When updating the field with the same information that is already in it I get the Error:</p>
  
  <pre><code>SQL Server does not handle comparison of NText, Text, Xml, or Image data types.
  </code></pre>
  
  <p>Does anybody know why this might be happening?</p>
  
  <p>Thanks,
  Oliver</p>