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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:53:02+00:00 2026-05-24T00:53:02+00:00

I have a search method below using linq, my search citeria is based on

  • 0

I have a search method below using linq, my search citeria is based on one table so far but I have a particular citeria which requires another table :

Method:

public void search(string s)
{
     var db = new CommerceEntities();
     var products = 
         from p in db.Products
         where (p.ModelName != null && p.ModelName.Contains(s))
                || SqlFunctions.StringConvert((double) p.ProductID).Contains(s)
                || (p.ModelNumber != null && p.ModelNumber.Contains(s))
                || (p.Description != null && p.Description.Contains(s))
                || SqlFunctions.StringConvert((double) p.CategoryID).Contains(s)
                || //stuck - See comment below

/* so far all in 'products' table, but I have one more citeria here that needs 'categories' table.
Ok, the query in SQL statement will be like this:

select ProductID, ModelName, ProductImage, Unitcost, products.Categoryid
from categories 
join products
on (categories.CategoryID = products.categoryID)
where categories.categoryname = 'necklace' (replace necklace with my parameter 's')
order by products.ModelName

I am not sure how to 'integrate' it with my existing linq query. Please kindly advice. Thanks.
*/
         select new
         {
             // Display the items 
             p.ProductID,
             p.ModelName,
             p.ProductImage,
             p.UnitCost,
             p.CategoryID,
         };

     ListView_Products.DataSourceID = null;
     ListView_Products.DataSource = products;
}
  • 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-24T00:53:03+00:00Added an answer on May 24, 2026 at 12:53 am
    var products = from p in db.Products
                join c in categories on c.CategoryID  equals p.categoryID
                where (/* all you conditions in either tables  */)
                select new
                {
                   p.ProductID,
                   p.ModelName,
                   p.ProductImage,
                   p.UnitCost,
                   p.CategoryID
                   /* plus what ever you want from categories */
                };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a LINQ method for the Search page of an in house app.
I have a rails helper using the structore below, but when I use it
I have a search method that takes in a user-entered string, splits it at
I have a datatable with as search fields. I want a method on the
I have search through the web to figure this out but no luck. I
I have search strings, similar to the one bellow: energy food olympics 2010 Terrorism
the div on website below that have search at the bottom and it always
I have controller method in my MVC application that I am calling using the
i have defined a route as below: context.MapRoute(SearchEngineWebSearch, search/web/{query}/{index}/{size}, new { controller = search,
Question Summary: Is there a better method than the one posted below to implement

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.