使用foreach从表中获取每个值.

编程入门 行业动态 更新时间:2024-10-23 21:40:33
本文介绍了使用foreach从表中获取每个值.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在项目中使用实体框架. 现在正在使用

I am using an entity frame work in my project. now am using

var list = from s in _db.Lists select s;

用于从表中获取所有值. 我怎样才能从表中只获得两列? 之后,我必须使用foreach循环从表中获取每个值.我该怎么办呢? 在此先感谢

this for taking all the values from the table. how can i get only two columns from a table.? after that i have to take each value from the table using a foreach loop.How can i do this??? Thanks in advance

推荐答案

要只获取一些列,您需要创建一个投影 To get only some columns you need to create a projection var list = from s in db.Lists select s.column1, s.column2

更多推荐

使用foreach从表中获取每个值.

本文发布于:2023-10-09 18:32:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476452.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:foreach

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!