In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "LINQ to SQL dynamic query example Analysis". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
LINQ to SQL dynamic query
Using LINQ to SQL dynamic queries, this example uses the CreateQuery () method to create a statement that outputs the query with an expression of type IQueryable.
Here's an example:
Var C1 = Expression.Parameter (typeof (Customer), "c"); PropertyInfo City = typeof (Customer) .GetProperty ("City"); var pred = Expression.Lambda (Expression.Equal (Expression.Property (C1, City), Expression.Constant ("Seattle"), C1); IQueryable custs = db.Customers; Expression expr = Expression.Call (typeof (Queryable), "Where", new Type [] {custs.ElementType}, custs.Expression, pred); IQueryable Q = db.Customers.AsQueryable (). Provider.CreateQuery (expr)
The Log property is used to print SQL queries or commands to TextReader. This approach can be useful for understanding LINQ to SQL functionality and debugging specific problems.
The following example uses the Log property to display the SQL code in the console window before it is executed. We can use this property with query, insert, update, and delete commands.
/ / turn off log function / / db.Log = null; / / use log function: log output to console window db.Log = Console.Out; var Q = from c in db.Customers where c.City = = "London" select c; / / log output to file StreamWriter sw = new StreamWriter ("log.txt"), true); db.Log = sw; var q = from c in db.Customers where c.City = = "London" select c Sw.Close (); "LINQ to SQL dynamic query example Analysis" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 239
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.