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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:27:34+00:00 2026-06-02T00:27:34+00:00

How to use properly the code below? public IEnumerable<T> Find(Expression<Func<T, bool>> predicate) I need

  • 0

How to use properly the code below?

public IEnumerable<T> Find(Expression<Func<T, bool>> predicate)

I need to return an IEnumerable of a particular object but I need to convert the collection object to a Queryable and convert the result again to List?

Below is my implementation, I don’t know if this is correct, I am using the code to unit test the generic repository.

 public IEnumerable<tbl_SBAem_Attendee> Find(Expression<Func<tbl_SBAem_Attendee, bool>> predicate)
        {
            var listtblsbaemAttendee = new  List<tbl_SBAem_Attendee>();
            IEnumerable<tbl_SBAem_Attendee> enumerableAttendee=new List<tbl_SBAem_Attendee>();


            for (var i = 0; i < 10; i++)
            {
                var tblSbAemAttendee = new tbl_SBAem_Attendee
                                           {
                                               AT_AID = i,
                                               AT_Address = "Address1" + i,
                                               AT_Address2 = "Address2" + i,
                                               AT_City = "City",
                                               AT_Email = "rene_florendo2005@yahoo.com.ph",
                                               AT_EventID = null,
                                               AT_FirstName = "Rene" + i,
                                               AT_LastName = "Florendo" + i,
                                               AT_GID = null,
                                               AT_Org = "Rene's Club",
                                               AT_Phone = "888-8888",
                                               AT_Phone2 = "999-8888",
                                               AT_RegID = null,
                                               AT_SendInfo = null,
                                               AT_State = "NJ",
                                               AT_Title = "Mr",
                                               AT_Zip = "4102",
                                               AT_date = null,
                                               AT_opt1 = "option1",
                                               AT_opt2 = "option2",
                                               AT_opt3 = "option3",
                                               AT_opt4 = "option4",
                                               AT_opt5 = "option5",
                                               AT_opt6 = "option6",
                                               AT_userID = null,
                                               AttendeeID = 1
                                           };
                listtblsbaemAttendee.Add(tblSbAemAttendee);
            }
            var result= listtblsbaemAttendee.AsQueryable().Where(predicate);
            return result.ToList();
        }

Any help or suggestions is highly appreciated.
Thank you.

  • 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-02T00:27:37+00:00Added an answer on June 2, 2026 at 12:27 am

    If i’m not wrong :

    Where(Expression<Func<T, bool>>) is an extension for a IQueryable

    but

    Where(Func<T, bool>>) is an extension for an IEnumerable.

    So try to change the parameter type of your function (or overload it), and you won’t need to cast to Queryable to use your predicate (don’t think that you need Expression)

    EDIT

    The other way would be to Compile your expression (var predicatefunc = predicate.Compile()), and use it in your “Where” clause. But I don’t think that’s the best way…

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

Sidebar

Related Questions

Is it normal to use default strategy like in my code below: public abstract
Below is some code I use to get the initial state of all public
I am running a basic GWT application in IntelliJ, below is my code public
I was trying to use tis depencency property in my code but it gives
Why cant i use code nuggets to set a control property??For example a validationgroup
I'm trying to use JQuery Slidetoggle functionality, but not able to use properly. The
I'm trying to use JQuery toggle functionality, but not able to use properly. Instead
I am trying to use vim properly - to aid me I've mapped my
I am trying to properly use Ninject to inject log4net logging into my MVC3
I'd like to know how to properly use connection pooling with Active MQ. Currently

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.