LINQ使用Lambda表达式选择几列
标签:
JavaScript
学习LINQ的Lambda的表达式,尝试从数据集合中,选择其中几列。
创建一个model:
source code:
namespace Insus.NET.Models{ public class ProdImage { public int ProductID { get; set; } public int Type { get; set; } public int Priority { get; set; } public string Url { get; set; } public string Alt { get; set; } public string Creator { get; set; } public DateTime CreateOn { get; set; } }}
View Code
我们再创建一个实体:
source code:
namespace Insus.NET.Entities{ public class ProdImageEntity { public IEnumerable<ProdImage> GetProdImage = new List<ProdImage> { new ProdImage { ProductID = 1,Type=12, Priority=45, Url = "http://insus.cnblogs.com", Alt="Insus blogs", Creator ="Insus.NET", CreateOn=Convert.ToDateTime("2016-04-13")}, new ProdImage { ProductID = 2,Type=18, Priority=38, Url = "http://www.cnblogs.com/insus", Alt="Insus blogs", Creator ="Insus.NET", CreateOn=Convert.ToDateTime("2016-04-18")} }; }}
View Code
接下来,我们就可以演示:
ProdImageEntity pie = new ProdImageEntity();
你可以选择全部:
在标题中,我们需要选择其中几个字段:
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦