本篇文章主要介绍了" SQL Queries from Transactional Plugin Pipeline",主要涉及到方面的内容,对于企业开发感兴趣的同学可以参考一下:
Sometimes the LINQ, Query Expressions or Fetch just doesn't give you the ability...
Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext)
serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));
object platformContext = context.GetType().InvokeMember("PlatformContext", System.Reflection.BindingFlags.GetProperty, null, context, null);
SqlTransaction tx = (SqlTransaction)platformContext.GetType().InvokeMember("SqlTransaction", System.Reflection.BindingFlags.GetProperty, null, platformContext, null);
DataSet result = SqlHelper.ExecuteDataset(tx, CommandType.Text, "SELECT ...");
You can also call a stored procedure in a different database that points back to the MSCRM database if you have complex queries. You'll need to use 'SET TRUSTWORTHY ON' to ensure that the security context is passed between the two databases.
My advice would be to only use this method only where using the SDK is just not possible or performs too slowly.
Hope this helps.
from: http://www.develop1.net/public/post/SQL-Queries-from-Transactional-Plugin-Pipeline.aspx
以上就介绍了 SQL Queries from Transactional Plugin Pipeline,包括了方面的内容,希望对企业开发有兴趣的朋友有所帮助。
本文网址链接:http://www.codes51.com/article/detail_2036418_2.html