我正在写一个Web API
问题描述:
我写这个查询从sql server获取数据时执行此操作它返回所有表而不是表上的所有数据
plz帮助我这个如何获取所选单个表的数据列我在一个表中有4列
我只想要其中两个感谢
i write this query for get data from sql server when execute this it returns all data for all table instead of on table
plz help me about this how can i get data of single table of selected columns i have 4 columns in one table
and i just want two of them thanks
namespace newAPI.Models
{
public class registered
{
private static HMISEntities dbcontxt = new HMISEntities();
public static List<registration> GetAllregis()
{
var query = from registration in dbcontxt.registrations
select registration;
return query.ToList();
}
}
}
答
var query = (from registration in dbcontxt.registrations
select new registration{ Id, Name}).ToList();
应该有效。
-KR
Should work.
-KR