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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:28:38+00:00 2026-05-13T23:28:38+00:00

I have the following link function MyLinqToSQLTable.Where(x => x.objectID == paramObjectID).ToList(); I most of

  • 0

I have the following link function

MyLinqToSQLTable.Where(x => x.objectID == paramObjectID).ToList();

I most of the time you can change a linq call to be several lines by adding curly brackets around the method body. Like this:

MyLinqToSQLTable.Where(x =>
{ 
    x.objectID == paramObjectID;
}).ToList();

Problem is the implied return that was there when I just did a Boolean compare is now not done. Return (x.objectID == paramObjectID); is not accepted either.

How do do this? can I do this?

NOTE: I know that I can add another where clause if needed. But I would still like to know the answer to this.

  • 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-13T23:28:38+00:00Added an answer on May 13, 2026 at 11:28 pm

    Your first query is equivalent to this one:

    MyLinqToSQLTable.Where(x =>
    { 
        return x.objectID == paramObjectID;
    }).ToList();
    

    You are missing the return keyword here. It’s necessary when the lambda body is an explicit block rather than an expression.

    The spec formally defines lambda-expression in grammar like:

    lambda-expression:
          anonymous-function-signature => anonymous-function-body

    anonymous-function-body:
          expression
          block

    The former case (expression) applies when the body doesn’t begin with a left curly brace. The latter case (block) is defined as a series of statements (just like a method body). Like other places in C#, expression statements in a block are restricted to declarations, assignments, function call, increment, and decrement. Merely applying operator == to a couple identifiers doesn’t the expression a valid statement. The second issue is that when the return type of a method (anonymous or not) is not void, all code paths reaching the end of the block should return a value. Consequently, even if the body of your lambda was syntactically valid, without a return statement, your lambda would be convertible to Action<T>, and not Func<T, bool> that Where method expects.


    Update:

    Problem is the implied return that was there when I just did a Boolean compare is now not done. Return (x.objectID == paramObjectID); is not accepted either.

    Of course, the x => { return x.objectID == paramObjectID; } variant of your lambda expression is only possible when it’s supposed to be converted to an anonymous method, not an expression tree. That is, a lambda with a block body is not convertible to Expression<T>. That’s why you can use it in LINQ to Objects (in which Where takes Func<T, bool>) but you can’t use it in LINQ to SQL (in which Where takes Expression<Func<T, bool>>).

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

Sidebar

Related Questions

I have tried to do this refering to following link. http://skypher.com/index.php/2008/07/28/function-list-for-php/ But no success.
I have the following bit of code, simply: $(function() { $('a.add-photos-link').live('click', function(e) { $(this).colorbox({
I have the following link: x = <a href=https://t.co/LwlI7i81>https://t.co/LwlI7i81</a> how can I use javascript
I have the following code: $(a.sticky-link).click(function (e) { e.preventDefault(); $(div.stickies-box).slideToggle('slow'); $(a.sticky-link).toggleClass(selected); }); $(div.stickies-box).mouseup(function ()
I have the following code: $('a.home-page-link').mouseover(function() { $(this).animate({ opacity: 0.4 }, 200, function()); });
I have the following JavaScript code: Link In which the function makewindows does not
Kindly have a visit on following link: Demo link for problem You can view
I have the following function: function parseLink(link){ var newlink=; $.get(link, function(data){ startoffset = data.indexOf(location.replace)
I'm using Fancybox 1.3.4 with ASP.NET MVC 3. I have following link : <a
I have the following output (via link) which displays the var_dump of some XML

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.