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 8799643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:22:43+00:00 2026-06-14T00:22:43+00:00

List<tblX> messages = (from x in db.tblX where x.msg_id == id_id || x.name ==

  • 0
List<tblX> messages = (from x in db.tblX where x.msg_id == id_id 
                           || x.name == firstName  select x).ToList();

I get the error:

The property ‘x’ on ‘tblX’ could not be set to a ‘null’ value. You must set this property to a non-null value of type ‘Int16’.

I have a property msg_blocked in db, which is nullable and integer. I know that I need to make a conversion, but I don’t use it or need it anywhere in my linq.

  • 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-06-14T00:22:45+00:00Added an answer on June 14, 2026 at 12:22 am

    Seems like your class definition for tblX doesn’t match the database representation, so either modify your class to accept a nullable value, or just project out the required fields:

    List<tblX> messages = (from x in db.tblX 
                       where (x.msg_id == id_id || x.name == firstName)
                       select new tblX
                       {
                        //required fields
                        msg_id = x.msg_id,
                        name = x.name,
                        ...
                       }).ToList();
    

    Addendum: The reason you run into this problem is behind the scenes when you
    select x
    this is translated into a
    select new tblX
    which projects into all its available fields. The code provided is more explicit and specifies which fields to query for and then project into.

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

Sidebar

Related Questions

List<int> result1 = (from number in list where number < 3 select number).ToList(); List<int>
List<int> types = Hospitals.GroupBy(h => h.TypeId, (key, group) => group.First()) .Select(t=> y.TypeId).ToList(); Trying to
List<MyClass> myclassList = (List<MyClass>) rs.get(); TreeSet<MyClass> myclassSet = new TreeSet<MyClass>(myclassList); I don't understand why
List<Car> oUpdateCar = new List<Car>(); oUpdateCar.Add(new Car()); oUpdateCar[0].name = Color; oUpdateCar[0].value = red; oUpdateCar.Add(new
List<String> s1; List<String> s2; I want to move n item from s1 to s2
List (and List) instances can be readonly, seeing ReadOnly property; methods throws exceptions in
List esns=session.createQuery(from Pool e where e.status=:status + order by uuid asc) .setString(status, AVAILABLE) .setMaxResults(n)
List<Student> liStudent = new List<Student> { new Student { Name=Mohan,ID=1 }, new Student {
list = [['John',3]['Carey',4]['Jake',3]] I'm looking for a way to select the data of a
List<String>[] stringList = new List<?>[10]; gives Type mismatch: cannot convert from List<?>[] to List<String>[]

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.