温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何解决LINQ泛型数据集问题

发布时间:2021-12-02 09:38:08 来源:亿速云 阅读:82 作者:小新 栏目:编程语言

这篇文章主要为大家展示了“如何解决LINQ泛型数据集问题”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“如何解决LINQ泛型数据集问题”这篇文章吧。

查询是一种从数据源检索数据的表达式。查询用专用查询语言表示。随着时间的推移,人们已经为不同类型的数据源开发了不同的语言,例如,用于关系数据库的 SQL 和用于 XML 的 XQuery。这使应用程序开发人员必须针对所支持的每种数据源或数据格式而学习新的查询语言。

语言集成查询 (LINQ) 通过提供一种跨各种数据源和数据格式使用数据的一致模型,简化了这一情况。在 LINQ 查询中,始终会用到对象。在查询和转换 XML 文档、SQL 数据库、ADO.NET 数据集和实体、.NET Framework 集合中的数据以及具有相应的 LINQ 提供程序的任何其他源或格式的数据时,都会使用相同的基本编码模式。

定义一个返回LINQ泛型数据集代码:

  1. using System;  

  2. using System.Collections.Generic;  

  3.  

  4. namespace BlueCube.BusinessLogic  

  5. {  

  6.  

  7. /// <summary> 

  8. /// Encapsulates execution result contains whether the 
    execution is successful and what messages the invoker will receive.  

  9. /// </summary> 

  10. public class ExecutionResult<T> 

  11. {  

  12. /// <summary> 

  13. /// True as execution is successful. False as failed.  

  14. /// </summary> 

  15. public bool Success  

  16. {  

  17. get;  

  18. set;  

  19. }  

  20.  

  21. private List<string> _Messages = null;  

  22.  

  23. /// <summary> 

  24. /// Stores message list  

  25. /// </summary> 

  26. public List<string> Messages  

  27. {  

  28. get  

  29. {  

  30. // Initialize message list if it is null  

  31. if (_Messages == null)  

  32. {  

  33. _Messages = new List<string>();   

  34. }  

  35. return _Messages;  

  36. }  

  37.  

  38. set  

  39. {  

  40. // Clear existed message list then add new list from value  

  41. if (_Messages != null)  

  42. {  

  43. _Messages.Clear();  

  44. foreach (string message in value)  

  45. {  

  46. _Messages.Add(message);  

  47. }  

  48. }  

  49. else  

  50. {  

  51. _Messages = value;  

  52. }  

  53. }  

  54. }  

  55.  

  56. /// <summary> 

  57. /// Encapsulates the value if there is any return value during execution  

  58. /// </summary> 

  59. public T ReturnValue  

  60. {  

  61. get;  

  62. set;  

  63. }  

  64. }  

以上是“如何解决LINQ泛型数据集问题”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI