.Net ObjectContext.CreateQuery(String, ObjectParameter[]) Method

public System.Data.Objects.ObjectQuery<T> CreateQuery<T> (string queryString, params System.Data.Objects.ObjectParameter[] parameters);

Examples

This example is based on the Microsoft SQL Server Product Samples: Database.

The example creates a simple query and iterates through the collection of results.

C#
using (AdventureWorksEntities context =
    new AdventureWorksEntities())
{
    string queryString =
        @"SELECT VALUE contact FROM AdventureWorksEntities.Contacts
            AS contact WHERE contact.FirstName = @fn";

    ObjectQuery<Contact> contactQuery =
        context.CreateQuery<Contact>(queryString,
            new ObjectParameter("fn", "Frances"));

    // Iterate through the collection of Contact items.
    foreach (Contact result in contactQuery)
        Console.WriteLine("First Name: {0}, Last Name: {1}",
        result.FirstName, result.LastName);
}

 

.Net ObjectContext.CreateQuery<T>(String, ObjectParameter[]) Method

上一篇:一文带你了解Web前端发展历程


下一篇:RoadFlow .NET Core 工作流引擎部署在Linux环境注意事项