学习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; }
}
}
我们再创建一个实体:
source code:
namespace Insus.NET.Entities
{
public class ProdImageEntity
{
public IEnumerable<ProdImage> GetProdImage = new List<ProdImage>
{
new ProdImage { ProductID = ,Type=, Priority=,
Url = "http://insus.cnblogs.com", Alt="Insus blogs",
Creator ="Insus.NET", CreateOn=Convert.ToDateTime("2016-04-13")}, new ProdImage { ProductID = ,Type=, Priority=,
Url = "http://www.cnblogs.com/insus", Alt="Insus blogs",
Creator ="Insus.NET", CreateOn=Convert.ToDateTime("2016-04-18")}
};
}
}
接下来,我们就可以演示:
ProdImageEntity pie = new ProdImageEntity();
你可以选择全部:
在标题中,我们需要选择其中几个字段: