我有以下功能,我正在返回员工列表。如果数据库中没有列表,我需要返回httpstatusErrorcode
错误信息
public List<SelectEventsMClass> FetchAllEmployes(int EmployTypeID)
{
try
{
var EventsList = new List<SelectEventsMClass>();
Employ.Data.EmployTableAdapters.EventsMSelectAllTableAdapter Adp = new Data.EmployTableAdapters.EventsMSelectAllTableAdapter();
Employ.Data.Employ.EventsMSelectAllDataTable Dtl = Adp.GetData(intEventTypeID);
if (Dtl.Rows.Count > 0)
{
var EventsList = (from lst in Dtl.AsEnumerable()
select new SelectEventsMClass
{
TransID = lst.Field<Guid>("TransID"),
SchoolTransID = lst.Field<Guid>("SchoolTransID"),
AcadamicTransID = lst.Field<Guid>("AcadamicTransID"),
EventTypeID = lst.Field<int>("EventTypeID"),
EventTitle = lst.Field<string>("EventTitle"),
}).ToList();
}
return EventsList;
}
catch (Exception ex)
{
throw ex;
}
}