- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
获取linq的sql语句(Get the SQL statement of LINQ)
获取linq的sql语句(Get the SQL statement of LINQ)
Linq facilitates our operation of the database and operates the database directly with the syntax of C#. But Linq also hides the actual execution of SQL statements. Encapsulation is good, but sometimes you have to understand Linqs specific operations on the database. For example, you can only optimize the database or query statement by looking at the actual SQL statement, and its frustrating to not see SQL at debug time.
There are several ways to dig out the Sql statements used in the operation:
1. Get the SqlCommand object corresponding to Query:
In the development process, we can obtain the corresponding Sql Command object through Query. Please see the following code:
AdventureWorksDataContext DB = new, AdventureWorksDataContext ();
Var products = from, P, in, db.Products
Where p.ProductID = = 3
Select, new, {p.ProductID, p.Name};
Foreach (VaR, P, in, products)
{
Console.WriteLine (P);
}
DbCommand CMD = db.GetCommand (products);
Console.WriteLine (-);
Console.WriteLine (Command Text: \n{0}, cmd.CommandText);
Console.WriteLine (-);
Console.WriteLine (Command Type: \n{0}, cmd.CommandType);
Console.WriteLine (-);
Console.WriteLine (Command Parameters:);
Foreach (DbParameter, P, in, cmd.Parameters)
{
Console.WriteLine ({0}: {1}, p.ParameterName, p.Value);
}
Console.ReadLine ();
The output is as follows:
Command Text:
SELECT, [t0].[ProductID], [t0].[Name]
FROM [Production].[Product] AS [t0]
WHERE [t0].[ProductID] = @p0
-
Command Type:
Text
-
Command Parameters:
@p0: 3
As you can see, both the Sql statement and the arguments are printed out. In fact, since weve got the full SqlCommand object, we can get more information than just these.
2, the use of LINQ to SQL Debug Visualizer:
Using LINQ to SQL Debug Visiualizer, we can intuitively obtain the Sql statements and parameters corresponding to Query without having to obtain the SqlCommand object and print information when debugging the program. For specific use, see this blog po
您可能关注的文档
- 老年痴呆病人的护理(Nursing care of senile dementia patients).doc
- 老手总结医疗营销宣传大法(Veteran summed up the medical marketing propaganda law).doc
- 老板为何不将人才摆在战略高位上(Why doesn't the boss put talent on strategic heights).doc
- 老板,请不要拖企业的后腿!(Boss, please don't drag the back of the business!).doc
- 老板讲历开服装店的经验(The boss talked about the experience of opening a clothing store).doc
- 老梁语录(Laoliang quotations).doc
- 老款桑塔纳机油灯控制原理(Control principle of oil lamp of old Santana).doc
- 老款车系(Old car system).doc
- 老花眼妙法!45---56岁间的男女值得关注(The presbyopia! 45---56 years old men and women worthy of attention).doc
- 老生常谈以客户为导向(Customer oriented).doc
- 获取免费流量的10种可观方法(10 sensible methods for getting free traffic).doc
- 茧丝横扫虎年 高位缓回兔年(The high silk swept slowly back to the year of the rabbit).doc
- 获取 成功 人生 的40条 守则(40 rules for success in life).doc
- 获取各种常用时间方法(Get all kinds of common time methods).doc
- 获取别人的IP(Get someone else's IP).doc
- 获取手机Root权限(Get mobile Root privileges).doc
- 获取服务器文件路径(Gets the server file path).doc
- 获取硬盘的详细信息(Get detailed information about the drive).doc
- 获得句柄(Get handle).doc
- 获取IP(Get IP).doc
最近下载
- 电子产品灌封机清洁验证方案.docx VIP
- 2025脓毒症诊断与治疗规范.docx VIP
- 文件盒正面标签标识.pdf VIP
- 二元一次方程组的解法80道计算题专训(8大题型)解析版-2024-2025学年北师大版八年级数学上册.pdf VIP
- 07SD101-8 电力电缆井设计与安装.docx VIP
- 22S521 预制装配式混凝土检查井.docx VIP
- 衡力(注射用A型肉毒毒素)说明书.pdf VIP
- SL∕T19-2023水利基本建设项目竣工财务决算编制规程.pdf VIP
- GB_T50817-2013:农田防护林工程设计规范.pdf VIP
- 2022年全国新高考“八省联考”高考语文适应性试卷(河北、广东、湖北、辽宁).docx
文档评论(0)