In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shares with you the content of a sample analysis of LINQ data sources. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
LINQ data source
In the previous example, because the data source is an array, it implicitly supports the generic IEnumerable) interface. This fact means that the data source can be queried using LINQ. Execute the query in a foreach statement, while foreach requires either IEnumerable or IEnumerable). Types that support IEnumerable) or derived interfaces (such as generic IQueryable) are called "queryable types".
The queryable type can be used as an LINQ data source without modification or special processing. If the LINQ source data does not already appear in memory as a queryable type, the LINQ provider must represent the source data in this way. For example, LINQ to XML loads an XML document into a queryable XElement type:
/ / Create a data source from an XML document. / / using System.Xml.Linq; XElement contacts = XElement.Load (@ "c:\ myContactList.xml")
In LINQ to SQL, you first create an object-relational mapping at design time either manually or by using the object-relational designer (Oram R designer). Queries are written against these objects, and then LINQ to SQL handles communication with the database at run time. In the following example, Customer represents a specific table in the database, and Table supports a generic IQueryable) interface derived from IEnumerable).
DataContext db = new DataContext (@ "c:\ northwind\ northwnd.mdf")
For more information about how to create specific types of data sources, see the documentation for various LINQ providers. But the basic rule is simple: a LINQ data source is any object that supports a generic IEnumerable) interface or an interface that inherits from that interface.
LINQ query
The query specifies the information to retrieve from the data source. Queries can also specify how the information is sorted, grouped, and structured before it is returned. Queries are stored in query variables and initialized with query expressions. To make it easier to write queries, C # introduces a new query syntax.
The query in the previous example returns all even numbers from an array of integers. The query expression contains three clauses: from, where, and select. If you are familiar with SQL, you will notice that the order of these clauses is reverse to that in SQL. The from clause specifies the data source, the where clause applies a filter, and the select clause specifies the type of element returned These and other query clauses are discussed in detail in the section LINQ query expressions (C # programming Guide). It is important to note that in LINQ, the query variable itself does nothing and does not return any data. It simply stores the information necessary to generate results when the query is executed at a later time.
Thank you for reading! This is the end of this article on "sample Analysis of LINQ data sources". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.