In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the example analysis of LINQ query, the article is very detailed, has a certain reference value, interested friends must read it!
In previous versions of C #, developers used many different query languages to access different data sources. For example, to query a XML file, the developer will use XPath, and to query a SQL database, the developer will use SQL. This method was very effective in the past and is still the main way to access all kinds of data. However, this approach has some disadvantages. A significant disadvantage is that developers have to write query code in a different language than the one they currently use (such as SQL or XPath). Another disadvantage is that when executing certain query languages, such as SQL, developers must write mapping code to convert the query results into available C# business objects.
Clipping 3.0 introduces a new approach called language Integrated query (LINQ). With LINQ, developers can write code that can search any IEnumerable data source. So in addition to using TSQL to access MS SQL database and XPath to access XML files, they can also apply LINQ.
The following code (listing C) is an example of a LINQ query that returns all customers whose OrderCount is greater than 10:
Using System; using System.Query; using System.Collections.Generic; public class SampleClass {static void Main () {List customers = GetCustomers (); / / Write our query to retrieve customers who have more than / / 10 orders. IEnumerable queryResult = from customer in customers where customer.OrderCount > 10 orderbycustomer.ID select customer;}}
Unlike SQL or XPath, LINQ queries are written in caching rather than in a third-party language. In this way, there will be no type problems with the query, and there is no need for developers to write mapping code to convert the data returned by the query into C # objects, and LINQ API will automatically handle the mapping.
Basically, LINQ objects are of great use in ORM solutions. Similarly, its scope is very wide, and there is a lot of MSDM information describing its functions.
The above is all the content of the article "sample Analysis of LINQ query". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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: 0
*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.