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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:42:42+00:00 2026-05-11T02:42:42+00:00

Im having problems building a query with the linq to sql data query expression

  • 0

Im having problems building a query with the linq to sql data query expression in c#.

What I’m trying to ultimately do is based on this pseudo-code expression.

public IQueryable<CTest> searchRecords(string category, string searchString, DateTime startDate, DateTime endDate, int searchType, int searchType2)         {             //-Search All Records             //-From the information table             //-By the category column containing a specific search             //-Also by             //  ~if both a startDate and endDate are entered (not (0000,00,00) OR null) then get records             //  by this expression             //  ~else then don't worry about this statement             //-Also by             //  ~if a searchType is equal zero(0) then search for records from the              //  search_type table equal to zero(0)             //  ~if a searchType is equal one(1) then search for records from the              //  search_type table equal to one(1)             //  ~else then don't worry about this statement             //-Also by             //  ~if a searchType2 is equal zero(0) then search for records from the              //  search_type table equal to zero(0)             //  ~if a searchType2 is equal one(1) then search for records from the              //  search_type table equal to one(1)             //  ~else then don't worry about this statement              //Here is my attempt at it             /*                   var table = db.table1;                  switch (category)                 {                 case '_category1':                     var records =                         from c in table                         where c.column1.ToString().Contains(searchString)                         select new CTest                         {                             test_id = c.id,                             test_name = c.name,                             test_number = c.number,                             date = ((startDate != null) && (endDate != null)) ? ((c.test_date >= startDate) && (c.test_date <= endDate)) :                                          c.test_date),                             test_type = (searchType == 0 ? (c.searchType = 0) :                                         searchType == 1 ? (c.searchType = 1) :                                         c.searchType),                             test_type2 = (searchType2 == 0 ? (c.searchType2 = 0) :                                         searchType2 == 1 ? (c.searchType2 = 1) :                                         c.searchType2)                         };                     break;                 default:                     break;                 }              */         } 

Thanks in advance.

  • 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. 2026-05-11T02:42:43+00:00Added an answer on May 11, 2026 at 2:42 am

    This would be easier to do with extension methods than LINQ syntax:

     var records = context.Table                       .Where( c => c.column1.Contains( searchString ) );  if (startDate != null && endDate != null)  {      records = records.Where( c => c.test_date >= startDate                                     && c.test_date <= endDate );  }   ... 

    This will build up the LINQ expression as you go along. The evaluation is delayed until you actually invoke some extension that requires the selection to be performed, like Count() or ToList(), or enumerate the elements of the result.

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

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Use git locally, and then git-cvsexportcommit would be my suggestion.… May 11, 2026 at 11:25 am
  • added an answer Turns out that in SSIS you can setup the OLE… May 11, 2026 at 11:25 am
  • added an answer Sessions are the way to go here, they are intended… May 11, 2026 at 11:25 am

Related Questions

Im having problems building a query with the linq to sql data query expression
Im having problems displaying records to my view when passing viewdata to a user
I'm having problems using textures that are larger than the OpenGL window or the
I'm having problems deciding on what is the best way is to handle and
I'm having problems with Iterator.remove() called on a HashSet. I've a Set of time
I'm having problems with my application receiving low memory warnings while the user is
I'm having problems with an SQL query used to display custom profile fields and
I'm having problems allocating and deallocating my memory in a recursive C++ program. So
I'm having problems redirecting stdio of another program using subprocess module. Just reading from
I'm having problems deploying a simple WebServices app (like Hello World simple) to OC4J.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.