您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“如何解決LINQ泛型數(shù)據(jù)集問題”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“如何解決LINQ泛型數(shù)據(jù)集問題”這篇文章吧。
查詢是一種從數(shù)據(jù)源檢索數(shù)據(jù)的表達(dá)式。查詢用專用查詢語言表示。隨著時(shí)間的推移,人們已經(jīng)為不同類型的數(shù)據(jù)源開發(fā)了不同的語言,例如,用于關(guān)系數(shù)據(jù)庫的 SQL 和用于 XML 的 XQuery。這使應(yīng)用程序開發(fā)人員必須針對(duì)所支持的每種數(shù)據(jù)源或數(shù)據(jù)格式而學(xué)習(xí)新的查詢語言。
語言集成查詢 (LINQ) 通過提供一種跨各種數(shù)據(jù)源和數(shù)據(jù)格式使用數(shù)據(jù)的一致模型,簡化了這一情況。在 LINQ 查詢中,始終會(huì)用到對(duì)象。在查詢和轉(zhuǎn)換 XML 文檔、SQL 數(shù)據(jù)庫、ADO.NET 數(shù)據(jù)集和實(shí)體、.NET Framework 集合中的數(shù)據(jù)以及具有相應(yīng)的 LINQ 提供程序的任何其他源或格式的數(shù)據(jù)時(shí),都會(huì)使用相同的基本編碼模式。
定義一個(gè)返回LINQ泛型數(shù)據(jù)集代碼:
using System;
using System.Collections.Generic;
namespace BlueCube.BusinessLogic
{
/// <summary>
/// Encapsulates execution result contains whether the
execution is successful and what messages the invoker will receive./// </summary>
public class ExecutionResult<T>
{
/// <summary>
/// True as execution is successful. False as failed.
/// </summary>
public bool Success
{
get;
set;
}
private List<string> _Messages = null;
/// <summary>
/// Stores message list
/// </summary>
public List<string> Messages
{
get
{
// Initialize message list if it is null
if (_Messages == null)
{
_Messages = new List<string>();
}
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;
}
}
}
/// <summary>
/// Encapsulates the value if there is any return value during execution
/// </summary>
public T ReturnValue
{
get;
set;
}
}
}
以上是“如何解決LINQ泛型數(shù)據(jù)集問題”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。