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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:37:15+00:00 2026-05-16T00:37:15+00:00

Struggling a bit today. I have the following method that returns a list of

  • 0

Struggling a bit today.

I have the following method that returns a list of products..lovely.

public static List<tblWeight> GetProductInfo(string memberid, string locationid, string basematerial, string source)
        {
             MyEntities getproductinfo = new MyEntities ();

            return (from p in getproductinfo .tblWeights
                        where    p.MemberId == memberid &&
                                 p.LocationId == locationid &&
                                 p.BaseMaterialName == basematerial &&
                                 p.WeightStatus == source
                       select p)
                       .ToList();
  • Where basematerial & source are drop down lists.

How do I go about incorporating a few IF statements into the where clause?

For example, if the basematerial ddl is not touched but an item in the source ddl is selected, the result would return everything associated with basematerial but filtered by the selected source.

Does that even make sense?!

I’m not even sure I am taking the correct approach – please forgive my ignorance.

  • 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-16T00:37:16+00:00Added an answer on May 16, 2026 at 12:37 am

    you can add them to your query on need:

    var r =  (from p in getproductinfo .tblWeights 
                            where    p.MemberId == memberid && 
                                     p.LocationId == locationid && 
                                     p.WeightStatus == source 
                           select p) 
    
    if (!String.IsNullOrEmpty(basematrial))
        r = r.Where(p => p.BaseMaterialName == basematerial);
    
    return r.ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

at work I am struggling a bit with the following situation: We have a
I am struggling a bit trying to achieve the following layout. I have the
So, I'm struggling a bit with my programming project. I have a object that
I'm struggling a bit to find the right place for a helper method. The
Im struggling a bit with the UIkeyboard, I have a datePicker, IntervalPicker some custom
I'm a bit struggling with the setup of my models. I have companies which
I'm struggling a bit with an excel calculation that needs to be written in
I'm still struggling a bit with the idea of ARC. Let's suppose I have
I'm struggling a bit with this. I want to get the list of ids
Struggling a bit on this... I'm using crontab for a lot of todo list

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.