In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is a LINQ expression". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is a LINQ expression".
Introduction to LINQ expression
Beyond 1.OO (object oriented): access and integration of information. Relational database and XML are typical applications.
2.NET Language Integrated Query (LINQ): instead of using proprietary solutions specific to relational databases or XML, general solutions are used to solve the problems of access and integration of various information sources.
3. In LINQ, query has become a part of programming language, which makes query expressions get the benefits of strongly typed languages such as compile-time syntax checking, rich metadata, intelligence awareness and so on.
Knowing LINQ expression for the first time
Class app {static void Main () {string [] names = {"Burke", "Connor", "Frank", "Everett", "Albert", "George", "Harris", "David"}; IEnumerable query = from s in names where s.Length = = 5 orderby s select s.ToUpper (); foreach (string item in query) Console.WriteLine (item);}}
Parsing of LINQ expression
IEnumerable query = from s in names where s.Length = = 5 orderby s select s.ToUpper ()
Semantically equivalent to the following "method-style (method-based) query":
IEnumerable query = names .Where (s = > s.Length = = 5) .OrderBy (s = > s) .Select (s = > s.ToUpper ())
LINQ expression parsing:
Func filter = delegate (string s) {return s.Length = = 5;}; Func extract = delegate (string s) {return s;}; Func project = delegate (string s) {return s.ToUpper ();}; IEnumerable query = names.Where (filter) .OrderBy (extract) .Select (project)
Query operator and extension method parsing:
Query operators are another important facility in LINQ expressions, and LINQ uses extension methods to define query operators, such as the where operator:
Namespace System.Linq {public static class Enumerable {public static IEnumerable Where (this IEnumerable source, Funcbool > predicate) {foreach (T item in source) if (predicate (item)) yield return item } Thank you for your reading, the above is the content of "what is a LINQ expression". After the study of this article, I believe you have a deeper understanding of what the LINQ expression is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.