In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 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 "how to use the Customers class of LINQ". In the operation of actual cases, many people will encounter such a dilemma, so 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!
What on earth is LINQ?
LINQ, whose full name is Language INtegrated Query, encapsulates operations such as Query and set operations, just like SQL statements queries implemented in .NET languages such as C # or VB.
Query expressions, that is, the query syntax implemented in SQL grammars such as "from", "where" and "select" that you are familiar with and are keen to use, as well as other implementations in C # and VB. Not only that, Query expressions can also be used to query data across application domains. In the following example, demonstrate how to query object data (Objects) as easily as data in a database (Database).
What does the code look like in LINQ?
The following example demonstrates querying a list of string data (list) and returning string data of length 5.
Using System; using System.Query; using Danielfe; class Program {static void Main (string [] args) {string [] aBunchOfWords = {"One", "Two", "Hello", "World", "Four", "Five"}; var result = from sin aBunchOfWords / / query the string array where s.Length = = 5 / / for all words with length = 5 select s; / / and return the string / / PrintToConsole is an Extension method that prints the value result.Print ();}}
The wonderful thing about LINQ is that you can use it to query any data. The following example demonstrates querying all Customer data with a Title length of 5 from SQL Server 2005:
Using System; using System.Query; using Danielfe; using System.Data.DLinq; / / DLinq is LINQ for Databases using nwind; / / Custom namespace that is tool generated class Program {static void Main (string [] args) {Northwind db = new Northwind ("Data Source= (local); Initial Catalog=Northwind;Integrated Security=True"); Table allCustomers = db.GetTable (); var result = from c in allCustomers where c.ContactTitle.Length = = 5 select c.ContactName; result.Print ();}}
The LINQ Customers class is an automatically generated class that can be accessed by your program corresponding to the database table (table) structure. The first two lines of the above code establish a database connection and get the data from the LINQ Customers table, and the next line queries all ContactTitle's LINQ Customers with a string length of 5 and returns their ContactName data, which is then output to the screen.
To put it simply, LINQ can easily access any data source in a unified and standard way (similar to SQL query statements).
This is the end of the content of "how to use the Customers class of LINQ". Thank you for 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: 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.