本文整理汇总了C#中DBContext.GetTable方法的典型用法代码示例。如果您正苦于以下问题:C# DBContext.GetTable方法的具体用法?C# DBContext.GetTable怎么用?C# DBContext.GetTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBContext
的用法示例。
在下文中一共展示了DBContext.GetTable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWorkZoneListSearch
public static List<WorkZoneListInfo> GetWorkZoneListSearch(int companyId, string WorkZoneName, string DateMin, string DateMax, string FactoryName,string MachineName)
{
if(DateMin==string.Empty)
DateMin ="1/1/1973";
if(DateMax ==string.Empty)
DateMax ="12/31/2999";
var context = new DBContext();
return (from w in context.GetTable<WorkZone>()
from f in context.GetTable<Factory>()
from m in context.GetTable<Machine>()
where
w.CompanyId == companyId
&& w.FactoryId == f.FactoryId
&& w.MachineId == m.MachineId
&& w.Name.Contains(WorkZoneName)
&& f.Name.Contains(FactoryName)
&& m.Name.Contains(MachineName)
&& w.ProgramDate >= Convert.ToDateTime(DateMin)
&& w.ProgramDate <= Convert.ToDateTime(DateMax)
select new
{
WorkZoneId = w.WorkZoneId,
Name = w.Name,
WorkZonePath = w.WorkZonePath,
ModelDataProgramer = w.ModelDataProgramer,
NCDataProgramer = w.NCDataProgramer,
ProgramDate = w.ProgramDate,
ModelName = w.ModelName,
Parts = w.Parts,
PartName = w.PartName,
MachiningTimeTotal = w.MachiningTimeTotal,
FactoryId = w.FactoryId,
FactoryName = f.Name,
MachineId = w.MachineId,
MachineName = m.Name,
Comment = w.Comment,
Status = w.Status,
ImageFile = w.ImageFile
}).AsEnumerable().Select(w => new WorkZoneListInfo
{
WorkZoneId = w.WorkZoneId,
Name = w.Name,
WorkZonePath = w.WorkZonePath,
ModelDataProgramer = w.ModelDataProgramer,
NCDataProgramer = w.NCDataProgramer,
ProgramDate = w.ProgramDate,
ModelName = w.ModelName,
Parts = w.Parts,
PartName = w.PartName,
MachiningTimeTotal = w.MachiningTimeTotal,
FactoryId = w.FactoryId,
FactoryName = w.FactoryName,
MachineId = w.MachineId,
MachineName = w.MachineName,
Status = w.Status,
Comment = w.Comment,
ImageFile = w.ImageFile
}).ToList();
}
示例2: GetListFactoryStatusFilter
public static List<FactoryStatus> GetListFactoryStatusFilter(int companyId, string factoryName, string fromDate, string toDate)
{
DateTime dtFrom = new DateTime(2000, 1, 1);
DateTime dtTo = new DateTime(2200, 1, 1);
if (!string.IsNullOrWhiteSpace(fromDate))
dtFrom = Convert.ToDateTime(fromDate);
if (!string.IsNullOrWhiteSpace(toDate))
dtTo = Convert.ToDateTime(toDate);
if (string.IsNullOrWhiteSpace(factoryName))
factoryName = "";
var context = new DBContext();
var query =
(from w in context.GetTable<WorkZone>()
join
f in context.GetTable<Factory>() on new { w.FactoryId } equals new { f.FactoryId }
where
(
f.CompanyId == companyId
&& w.CompanyId == companyId
&& f.Name.ToLower().Contains(factoryName.ToLower())
&& (w.ProgramDate != null && dtFrom.Date <= w.ProgramDate.Value.Date && w.ProgramDate.Value.Date <= dtTo.Date)
&& f.isDeleted == false
)
select new
{
ImageFile = f.ImageFile,
Status = WorkZoneDetail.GetStatusForWorkZone(w.WorkZoneId),
FactoryId = w.FactoryId,
FactoryName = f.Name
}
).GroupBy(p => new { p.FactoryId, p.FactoryName }).ToList();
List<FactoryStatus> list = new List<FactoryStatus>();
string companyPath = string.Format(Constant.PATH_COMPANY, companyId, Company.GetCompanyName(companyId));
foreach (var i in query)
{
FactoryStatus s = new FactoryStatus();
s.FactoryId = i.First().FactoryId;
s.FactoryName = i.First().FactoryName;
string factoryPath = string.Format(Constant.PATH_FACTORY, s.FactoryId, s.FactoryName);
s.ImageFile = string.IsNullOrEmpty(i.First().ImageFile) ? "" : string.Format(@"{0}{1}{2}/{3}", Common.AppSettingKey(Constant.PORTAL_CONFIG), companyPath, factoryPath, i.First().ImageFile.Replace(" ", "%20"));//Ima
s.InProcess = i.Where(p => p.Status == 0).Count();
s.HaveProblem = i.Where(p => p.Status == 1).Count();
s.Finished = i.Where(p => p.Status == 2).Count();
list.Add(s);
}
return list;
}
示例3: GetListWorkZoneStatusFromFactory
public static List<WorkZoneStatus> GetListWorkZoneStatusFromFactory(int FactoryId)
{
List<WorkZoneStatus> list = new List<WorkZoneStatus>();
var context = new DBContext();
list =
(from w in context.GetTable<WorkZone>()
join m in context.GetTable<Machine>() on new { w.MachineId } equals new { m.MachineId }
where
(
w.FactoryId == FactoryId
&& m.isDeleted == false
)
select new WorkZoneStatus()
{
WorkZoneId = w.WorkZoneId,
WorkZoneName = w.Name ,
CompanyId = w.CompanyId,
ImageFile = w.ImageFile,
Upload = string.Format("{0:yyyy-MM-dd}", w.ModifiedDate),
Machine = m.Name,
Operator = w.NCDataProgramer,
StatusId = WorkZoneDetail.GetStatusForWorkZone(w.WorkZoneId), //w.Status,
Date = !w.ProgramDate.HasValue ? "" : w.ProgramDate.Value.ToString(),
}
).ToList();
foreach (WorkZoneStatus i in list)
{
i.Status = Common.GetResourceString(string.Format("STATUS_{0}", i.StatusId));
if (i.Date != "")
i.Date = DateTime.Parse(i.Date).ToString("yyyy-MM-dd");
if (string.IsNullOrEmpty(i.ImageFile))
i.ImageFile = ""; //no image
else
{
string pathWorkZone = Common.GetFolderWorkZone(i.CompanyId, Company.GetCompanyName(i.CompanyId), FactoryId, Factory.GetFactoryName(FactoryId), i.WorkZoneId, i.WorkZoneName);
pathWorkZone = pathWorkZone.Replace("Portal", "");
i.ImageFile = string.Format(@"{0}{1}/{2}", Common.AppSettingKey(Constant.PORTAL_CONFIG), pathWorkZone, i.ImageFile).Replace(" ", "%20");
}
}
return list;
}