顯示具有 DotNetFramework-LINQ 標籤的文章。 顯示所有文章
顯示具有 DotNetFramework-LINQ 標籤的文章。 顯示所有文章

2013年4月10日 星期三

LINQ 表示式(5) - Concat、Union、Intersect、Except

關鍵字: Concat、Union、Intersect、Except

LINQ 表示式(4) - Exist、In、Any、All、Contains

關鍵字: Any、All、StartsWith、IndexOf、Contains

LINQ 表示式(3) - Join

關鍵字: Join

LINQ 表示式(2) - OrderBy 、 GroupBy 、 Into 、 Max 、 Min 、 Average 、 Sum 、 Count 、 Aggregate

關鍵字: OrderBy 、 GroupBy 、 Into 、 Count 、 Max 、 Min 、 Average 、 Sum 、 Aggregate

LINQ 資料格式轉換

LINQ 不僅僅可以用來查詢資料, LINQ 也允許我們將來源資料轉換成其他格式的資料。例如轉成 XML 或 JSON 格式,亦或是自訂型別都可以。

LINQ 表示式(1) - Select、Where、Distince

關鍵字: Select 、 Where 、 Distinct

2013年4月9日 星期二

LINQ to Entity

LINQ to Entities works in a manner that is similar to that of LINQ to SQL . You define a model to represent your application domain. You then create a map between this model and your actual data source. You can then load data into the model and query against it by using LINQ. However, LINQ to Entities uses the ADO.NET Entity Framework as a basis for the models. These models can be created for any data source (not just for SQL Server).

LINQ to XML

要查詢 XML 文件,除了使用 XQuery ,另一種方法就是使用 LINQ to XML 類別(們)。 這些類別都包含在 System.Xml.Linq 命名空間中, 除了提供簡單快速的方法可以用來查詢 XML 文件,且都使用與先前相同的查詢模組。

LINQ to SQL

由上節說明(Link to DataSet)可以知道中,透過 LINQ 可以很快速地查詢 DataSet 中的靜態資料。 但是這樣子並沒有顯現出 LINQ 最大的功能,那就是:設計階段強型別檢查 (strong type-checking at design time)。

要使用 LINQ to SQL 時,必須先建立連結到資料庫元素的 O/R map 。 這個 map 一旦建立,存取資料庫的語法就好像在寫物件式的程式碼,就變的既簡單又快速。

LINQ to DataSet

2012年11月15日 星期四

LINQ 入門(二)

Language-Integrated Query (LINQ) provides a consistent model for querying data no matter where that data comes from. This allows you to write .NET Framework code (in lieu of SQL) when working with data. LINQ gives you compile-time syntax checking against your data, static typing, and IntelliSense in the code editor. All of these features make programming data easier and more consistent, regardless of the origin of the data.

LINQ is an extension to the development languages of C# and Visual Basic. For more information on the LINQ language extensions, you can review the MSDN topic, Getting Started with LINQ in C#

2012年5月16日 星期三

LINQ 入門(三)關連性查詢

跨 Table 的關聯性查詢

直接使用物件模型中的關連

如果在資料庫中 Catalog 和 Documents 之間已經建立了關連性(外部索引鍵),在 linq 語法中,此時不需要在 Catalog 和 Documents 之間使用「聯結」(Join), 就可以直接從 Catalog 物件存取 Documents 物件。

2012年5月15日 星期二

LINQ 入門(一)

LINQ 簡介

MS 在 .NET Framework 3.5 版中,引進一個新的功能,稱之為 LINQ (Language Integrated Query)。 它是一種針對集合元素進行查詢的語言,如此一來,不管你使用何種資料來源,只要該資料是實作 IEnumerable 介面的物件,都可以使用單一的 LINQ 語法去查詢處理。

LINQ 使用類似 SQL 查詢的語法:
from 子句指定查詢來源;
where 子句設定篩選條件;
order by 子句做排序;
group by 子句對資料分組,
select 子句回傳資料。
而且,LINQ 查詢也支援複雜的 join 語法,這樣就可以在程式語言中,直接執行複雜的連結運算,以達到資料搜尋的目的。