In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use LINQ query". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use LINQ query.
LINQ is a feature provided in Visual Studio 2008 and later, extending powerful queries to C # and VB.NET language syntax. LINQ provides a standard, simple schema for querying and updating data, while allowing program developers to extend to support any type of data store. Visual Studio 2008 includes LINQ provider assemblies that can query .NET Framework collections, in-memory arrays of objects, SQL Server databases, ADO.NET Dataset and XML documents. In addition, we can also write our own LINQ provider to provide queries for any type of data, as long as we implement IEnumerable or IEnumerable (C #) or IEnumerable (Of T) (Visual Basic) data types, we can operate using LINQ. We can use exactly the same syntax to query SQL databases, XML documents, ADO.NET 's Dataset (DataTable), in-memory collection objects, and any remote or local data source that supports LINQ. In LINQ queries, you only deal with objects, so you don't need to know the data source of the data store at all, and you use exactly the same programming model and syntax.
All LINQ queries are basically composed of three basic operations: getting the data source, creating the query and executing the query. The acquisition of data is done when the query is executed.
NorthWindDataContext NorthWind = new NorthWindDataContext ()
Is to get the data source.
Var query = from c in NorthWind.
Customers where c.Country = = "USA" select new {c.Country, c.CompanyName}
Is to create a query with no action performed on the data at this time
GridView2.DataSource = query; GridView2.DataBind ()
When you bind the data, you really get the data.
However, some queries need to be executed immediately, put the results in memory, and you can call the ToList or ToArray methods of the query or query variables. For example:
Var query2 = from c in NorthWind.Customers where c.Country = =
"USA" select new {c.Country, c.CompanyName}
Var query3 = query2.ToList ()
OK, running this program may need to use simulation or adjust the permissions of Excel.exe, and note: before use, you need to reference COM:Microsoft Office 11.0 Object Library, if it is not in the reference list, you need to add C:\ Program Files\ Microsoft Office\ OFFICE11\ EXCEL.EXE).
At this point, I believe you have a deeper understanding of "LINQ query how to use", might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.