And another LINQ 101 bug...

M

Mike P

Here is another one I hope somebody can help me with, this is the
AnyGrouped example and does not recognise the 'Group' as being valid :

List<Product> products = GetProductList();

var productGroups =
from p in products
group p by p.Category into g
where g.Group.Any(p => p.UnitsInStock == 0)
select new { Category = g.Key, Products = g.Group };

foreach (var a in productGroups)
{
lbl.Text += a.Category + ":<br/>";

foreach (var b in a.Products)
{
lbl.Text += b + "<br/>";
}
}
 
R

raylopez99

Here is another one I hope somebody can help me with, this is the


These LINQ query errors remind me of SQL query errors--being off by a
parens or one small token is fatal. Good luck. It's a real dinosaur
construct (LINQ and SQL) IMO.

RL
 
A

Arne Vajhøj

raylopez99 said:
These LINQ query errors remind me of SQL query errors--being off by a
parens or one small token is fatal. Good luck. It's a real dinosaur
construct (LINQ and SQL) IMO.

What do you code in where being off by one parenthesis does not matter ?

Arne
 
R

raylopez99

What do you code in where being off by one parenthesis does not matter ?

Yes, I thought of this after I posted. What I'm trying to say is that
some languages are more forgiving than SQL, which tries to pack too
much into one line. Kind of like if / else statements that are
nested--sometimes it's better to have a case statement. But it's just
my newbie opinion.

RL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top