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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:19:20+00:00 2026-05-16T06:19:20+00:00

Given a class [Table ( Name = AllPlayerInfo ) ] public class AllPlayerInfo {

  • 0

Given a class

[Table ( Name = "AllPlayerInfo" ) ]
public class AllPlayerInfo
{
   [Column (IsPrimaryKey = true)]
   public decimal Classes_ID { get; set; }
   [Column (IsPrimaryKey = true)]
   public decimal Member_ID { get; set; }
   //...
}

I call

DataContext db2 = new DataContext ( sqlconnectstring );
Table<AllPlayerInfo> api = db2.GetTable<AllPlayerInfo> ();

which returns all the records from the database table.
I look at the contents of api and confirm that the record I want is there and has Member_ID == 4617.

So I issue following command:

AllPlayerInfo attempt1 = api.Where ( r => r.Member_ID == 4617).FirstOrDefault<AllPlayerInfo> ();

that (incorrectly) returns null.

So then I transfer the object to a list:

List<AllPlayerInfo> listapi = api.ToList<AllPlayerInfo> ();

and then use the Exists method and it does find the record I wanted:

bool recordexists = listapi.Exists ( r => r.Member_ID == 4617 );

recordexists is true!

So the question is: Why does the Where method not find the record when it is clearly there? I did try the Where method with other fields and values and they worked. Just not this particular field. I tested other decimal fields such as the class_id and it worked.

  • 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-16T06:19:20+00:00Added an answer on May 16, 2026 at 6:19 am

    I would check the generated SQL in SQL profiler. Sometimes when LINQ to SQL determines you are comparing incorrect types, e.g. Where(x => x.somestring == null) and x.somestring is not set as nullable in the DBML file then it generates SQL with a where clause that says WHERE 1=0 and then goes off and runs that in SQL server which will boviously return no records. Member ID is a decimal and it is probably inerpretting your literal as an int so it has decided that Where( r => r.Member_ID == 4617) cannot ever be true so it creates SQL that will never return any records.

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

Sidebar

Related Questions

Given the class: public class Item { [Key] public int ID { get; set;
Given the following POCO classes: public class Certification { public int Id { get;
Given a model's instance object, how can I get the database table's name? I
Using SQLAlchemy, given tables such as these: locations_table = Table('locations', metadata, Column('id', Integer, primary_key=True),
I have two entities: Event and Comment. @Entity @Table(name = events) public class Event
I'm writing a class that programmatically creates a table given certain column names. I'm
Given: class A { public void m(List l) { ... } } Let's say
Given: class example { public: std::vector<std::vector<int>> a; int b; } func() { example e;
I have method that returns module path of given class name def findModulePath(path, className):
I have the following entity (getters and setters ommited)... @Entity @Table(name = TBL_PROJECT_RUN) public

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.