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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:45:33+00:00 2026-05-26T14:45:33+00:00

What is wrong with this statment below? I get ; expected when run it

  • 0

What is wrong with this statment below? I get “; expected” when run it in LinqPad with language setting to “C# Statement”.

from p in Products where p.UnitPrice > 50 select new {p.ProductID };

Now seem like if I assign it to any var; I don’t get any error. But what I find confusing is the statement below works fine and give me results back although I don’t assign it to any variable. Any ideas?

    from p in Products
let spanishOrders = p.OrderDetails.Where ( o=> o.Order.ShipCountry == "Spain")
where spanishOrders.Any()
group new
{
    p.ProductName,
    Orders = spanishOrders.Count(),
    spanishOrders
}
by p.Category.CategoryName

EDIT: It was my bad actually i couldn’t run the second example without assigning it to a variable.

  • 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-26T14:45:33+00:00Added an answer on May 26, 2026 at 2:45 pm

    LINQ Query expressions are not legal statements in C#. You need to use the expression in a valid statement.

    For example, you could use the expression as the right-hand side of an assignment statement:

    var expensiveProductIds = from p in Products
                              where p.UnitPrice > 50 
                              select new { p.ProductID };
    

    It does appears to me like you don’t really understand what LINQ is all about. What did you expect your naked query expression to do?

    EDIT: Take a look at Alex Moore’s answer for how to get this to work in LINQPad.

    By the way, here’s a way to get the results of the query written to console if you still want to stick with the “C# Statement(s)” mode:

    var expensiveProductIds = from p in Products
                              where p.UnitPrice > 50 
                              select new { p.ProductID };
    
    expensiveProductIds.Dump();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The sql statement below will not run in SQLite: select * from A left
What is wrong with this statement? return Encoding.ASCII.GetString(memoryStream.GetBuffer(), 0, memoryStream.Length) I know about the
What is wrong with this statement? I`m having the following error: Error 10 'System.Web.Mvc.HtmlHelper'
Does anyone have any idea what is wrong with this create statement for mysql?
Hi can someone tell me what i'm doing wrong in this jquery statement. I
What's wrong with this function: function() { $.get('/controller/action', function(data) { $('#temporaryPhotos').text(data); } ); return
Can you figure out what is wrong with the statement below? GCC error states:
I would like to know if there is anything wrong with the below statement.
Whats wrong with this code? -(void) drawRect:(CGRect) rect { CGContextRef c = UIGraphicsGetCurrentContext(); if
Whats wrong with this picture? Model: validates_acceptance_of :terms_of_service, :on => :create, :accept => true,

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.