2
As quoted above, when I say equals
from LINQ to Entities I am referring specifically to the reserved word of C# and not to the Equals()
of System.Object
.
Source: equals (Reference of C#)
The following example returns all red products.
String color = "Red";
using (AdventureWorksEntities context = new AdventureWorksEntities())
{
var query =
from product in context.Products
where product.Color == color
select new
{
Name = product.Name,
ProductNumber = product.ProductNumber,
ListPrice = product.ListPrice
};
foreach (var product in query)
{
Console.WriteLine("Name: {0}", product.Name);
Console.WriteLine("Product number: {0}", product.ProductNumber);
Console.WriteLine("List price: ${0}", product.ListPrice);
Console.WriteLine("");
}
}
Source: Query expression syntax examples: filtering | Microsoft Docs
Doubt: What is the difference or impact when changing ==
for equals
? By making this change the select is mounted in the same way?
Obs: I don’t mean the method .Equals()
Thank you for the @Maniero reply, I was wondering that the equals could actually always be used to create a query in Brazilian, but there was no attack on the fact that it is specifically used next to the Join clause.
– Gean Miguel