次の違いは何ですか-
CreateQuery() ExecuteFunction(), ExecuteStoreQuery() and ExecuteStoreCommand()
私の知る限り、CreateQueryはEntity SQLに使用され、残りのメソッドはSQL関数またはDBで定義されたストアドプロシージャに使用されます。
ObjectContext クラスのメタデータによると、それらは次のとおりです。
CreateQuery():Creates an System.Data.Objects.ObjectQuery<T> in the current object context by using the specified query string.
Returned -> System.Data.Objects.ObjectQuery<T>
ExecuteFunction(): 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.
Returned -> The number of rows affected.
This has an overloaded version which return -> The entity type of the System.Data.Objects.ObjectResult<T>
ExecuteStoreCommand(): Executes an arbitrary command directly against the data source using the existing connection.
Return -> The number of rows affected.
ExecuteStoreQuery(): Executes a query directly against the data source that returns a sequence of typed results.
Return -> An enumeration of objects of type TResult.
上記の情報によると -
Use ExecuteFunction() if you have added db Function/Stored Procedure in your EDMX & can be used for both insert/update & getting result set.
Use ExecuteStoredCommand() if you have not added db Function/Stored Procedure in your EDMX & can be used to insert/update only.
ExecuteStoreQuery() can do what Executefuction() can do except that you no need to add your db Function/Stored Procedure in EDMX & IEnumerable can be used as return type.
間違っている場合は修正してください。さらなる情報をお待ちしております。