where p.ProductCategory.Name = @p0?

You use Microsoft .NET Framework 4.0 to develop an application that uses the Entity Framework.
The application defines the following Entity SQL (ESQL) query, which must be executed against the mode.

string prodQuery = select value p from Products as p where p.ProductCategory.Name = @p0?;

You need to execute the query. Which code segment should you use?

You use Microsoft .NET Framework 4.0 to develop an application that uses the Entity Framework.
The application defines the following Entity SQL (ESQL) query, which must be executed against the mode.

string prodQuery = select value p from Products as p where p.ProductCategory.Name = @p0?;

You need to execute the query. Which code segment should you use?

A.
var prods = ctx.CreateQuery<Product>(prodQuery, new ObjectParameter(“p0?, “Road Bikes”)).ToList();

B.
var prods = ctx.ExecuteStoreCommand(prodQuery, new ObjectParameter(“p0?, “Road Bikes”)).ToList();

C.
var prods = ctx.ExecuteFunction<Product>(prodQuery, new ObjectParameter(“p0?, “Road Bikes”)).ToList();

D.
var prods = ctx.ExecuteStoreQuery<Product>(prodQuery, new ObjectParameter(“p0?, “Road Bikes”)).ToList();

Explanation:
CreateQuery<T> – Creates an ObjectQuery<T> in the current object context by using the specified query string.
ExecuteStoreCommand – Executes an arbitrary command directly against the data source using the existing connection.
ExecuteFunction(String, ObjectParameter[]) – Executes a stored procedure or function that is defined in the data source and
expressed in the conceptual model; discards any results returned from the function; and returns the number of rows affected by the execution.
ExecuteStoreQuery<TElement>(String, Object[]) – Executes a query directly against the data source that returns a sequence of typed results.

ObjectContext.CreateQuery<T> Method
(http://msdn.microsoft.com/en-us/library/bb339670.aspx)



Leave a Reply 0

Your email address will not be published. Required fields are marked *