我正在写一个Web API [英] i am writing a web API
本文介绍了我正在写一个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
这篇关于我正在写一个Web API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文