ReSharper has proposed me to make the following changes:
From:
foreach (var item in db.Proposta.GroupBy(x => x.StatusProposta.Nome))
{
...
}
To:
foreach (var item in Queryable.GroupBy(db.Proposta, x => x.StatusProposta.Nome))
{
...
}
The message is: Invoke method ‘GroupBy’ as static method
I’m using Entity Framework and db is my context.
I wonder what advantages may I get or problems I can avoid with such a change.
Resharper is just offering it as something that it can do for you. It will likewise offer to convert the static method call into as an extension method invocation.
Really it is a matter of preference – there is no advantage of one over the other – they compile to the same thing, but you should use it as an extension method. It’s widely more popular to use the extension method syntax for extension methods rather than plain static calls when using LINQ.