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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:35:19+00:00 2026-05-26T16:35:19+00:00

I have defined a specification as an object of type Expression<Func<User, bool>> like this:

  • 0

I have defined a specification as an object of type Expression<Func<User, bool>> like this:

public static Expression<Func<User, bool>> IsSystemUser
{
  get
  {
    return user => user.UserID == -1;
  }
}

This works marvellously with queries written in extension method syntax:

return workspace.GetDataSource<User>().Where(UserSpecifications.IsSystemUser);

But not with Linq query syntax:

return from user in workspace.GetDataSource<User>() where UserSpecifications.IsSystemUser select user;

The compiler gives me cannot implicitly convert type 'Expression<Func<User, bool>>' to 'bool'.

What gives? I thought Linq query syntax was just a cute DSL dressing up the extension method syntax. Can anyone tell me how I might use my lovely specifications with Linq query syntax?

  • 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-26T16:35:20+00:00Added an answer on May 26, 2026 at 4:35 pm

    Your query expression is being translated into:

    return workspace.GetDataSource<User>()
                    .Where(user => UserSpecifications.IsSystemUser);
    

    The lambda expression is introduced implicitly – but you don’t want it in this case. So don’t use query expression syntax… Given that here the query expression syntax is longer than using the extension methods directly, and introduces more cruft, why would you want it?

    Note that you can mix and match like this:

    return from user in workspace.GetDataSource<User>()
                                 .Where(UserSpecifications.IsSystemUser)
           where user.Name == "Bob"
           orderby user.ID
           select user;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a specification defined as an Expression as below: public Expression<Func<Foo, bool>>
So I have a a text file that looks something like this: public >ret
I have a Func defined as follows: Func<Foo, bool> IsSuperhero = x => x.WearsUnderpantsOutsideTrousers;
I have defined a personalizable property on a web part and I would like
I have defined a custom list template type for SharePoint . I install it
I have defined a tag with a CSS attribute overflow set to scroll. This
I have a class that should look something like this: class Family_Type1 @people =
I am trying to use view animation on an Imageview object.I have defined a
I have defined a custom Sharepoint list for special attributes related to a software
I have defined an interface in C++, i.e. a class containing only pure virtual

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.