新聞中心
學(xué)習(xí)LINQ時,經(jīng)常會遇到LINQ泛型數(shù)據(jù)集問題,這里將介紹LINQ泛型數(shù)據(jù)集問題的解決方法。

膠州網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)建站!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)等網(wǎng)站項目制作,到程序開發(fā),運(yùn)營維護(hù)。創(chuàng)新互聯(lián)建站于2013年開始到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運(yùn)維經(jīng)驗,來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)建站。
查詢是一種從數(shù)據(jù)源檢索數(shù)據(jù)的表達(dá)式。查詢用專用查詢語言表示。隨著時間的推移,人們已經(jīng)為不同類型的數(shù)據(jù)源開發(fā)了不同的語言,例如,用于關(guān)系數(shù)據(jù)庫的 SQL 和用于 XML 的 XQuery。這使應(yīng)用程序開發(fā)人員必須針對所支持的每種數(shù)據(jù)源或數(shù)據(jù)格式而學(xué)習(xí)新的查詢語言。
語言集成查詢 (LINQ) 通過提供一種跨各種數(shù)據(jù)源和數(shù)據(jù)格式使用數(shù)據(jù)的一致模型,簡化了這一情況。在 LINQ 查詢中,始終會用到對象。在查詢和轉(zhuǎn)換 XML 文檔、SQL 數(shù)據(jù)庫、ADO.NET 數(shù)據(jù)集和實體、.NET Framework 集合中的數(shù)據(jù)以及具有相應(yīng)的 LINQ 提供程序的任何其他源或格式的數(shù)據(jù)時,都會使用相同的基本編碼模式。
定義一個返回LINQ泛型數(shù)據(jù)集代碼:
- using System;
- using System.Collections.Generic;
- namespace BlueCube.BusinessLogic
- {
- ///
- /// Encapsulates execution result contains whether the
execution is successful and what messages the invoker will receive.- ///
- public class ExecutionResult
- {
- ///
- /// True as execution is successful. False as failed.
- ///
- public bool Success
- {
- get;
- set;
- }
- private List
_Messages = null; - ///
- /// Stores message list
- ///
- public List
Messages - {
- get
- {
- // Initialize message list if it is null
- if (_Messages == null)
- {
- _Messages = new List
(); - }
- return _Messages;
- }
- set
- {
- // Clear existed message list then add new list from value
- if (_Messages != null)
- {
- _Messages.Clear();
- foreach (string message in value)
- {
- _Messages.Add(message);
- }
- }
- else
- {
- _Messages = value;
- }
- }
- }
- ///
- /// Encapsulates the value if there is any return value during execution
- ///
- public T ReturnValue
- {
- get;
- set;
- }
- }
- }
以上介紹定義一個返回LINQ泛型數(shù)據(jù)集。
標(biāo)題名稱:LINQ泛型數(shù)據(jù)集淺談
轉(zhuǎn)載來于:http://m.5511xx.com/article/cddpcso.html


咨詢
建站咨詢
