I recently came across the following Entity Framework syntax. Check out the where clause -
.Where("it.LastName = @ln AND it.FirstName = @fn")
What does it. do it. ? And why is it instead of Contacts.LastName? Any detailed information would be helpful. Thanks in advance.
string firstName = @"Frances"; string lastName = @"Adams"; using (AdventureWorksEntities context = new AdventureWorksEntities()) { // Get the contacts with the specified name. ObjectQuery<Contact> contactQuery = context.Contacts .Where("it.LastName = @ln AND it.FirstName = @fn", new ObjectParameter("ln", lastName), new ObjectParameter("fn", firstName)); // Iterate through the collection of Contact items. foreach (Contact result in contactQuery) Console.WriteLine("Last Name: {0}; First Name: {1}", result.LastName, result.FirstName); }
source share