var query = from entity in GetMaterialViewModelList()
select entity;
var result = from mcq in BOMDataBase.MD_MaterialCatQualities
join mc in BOMDataBase.MD_MaterialCategories on mcq.CategoryID equals mc.ID
join q in BOMDataBase.MD_Qualities on mcq.QualityID equals q.ID
select new
{
md_mcq = mcq,
md_mc = mc,
md_q = q
};
foreach (var o in result)
{
MD_MaterialCatQuality md_mcq = new MD_MaterialCatQuality();
md_mcq.MD_MaterialCategory = o.md_mc;
md_mcq.MD_Quality = o.md_q;
MaterialCatQualityModel materialCatQualityModel = new MaterialCatQualityModel();
materialCatQualityModel.ID = md_mcq.ID;
materialCatQualityModel.CategoryID = md_mcq.CategoryID;
materialCatQualityModel.QualityCode = o.md_q.Code;
materialCatQualityModel.QualityName = o.md_q.Name;
materialCatQualityModel.Quality = o.md_q;
listMaterialCatQualityModel.Add(materialCatQualityModel);
}
public List<TISTankDataModel> GetTISTankDataModelListByEqualsTimeStamp(DateTime startDateTime, DateTime endDateTime)
{
List<TISTankDataModel> listTISTankDataModel = new List<TISTankDataModel>();
EnumConvert enumConvert = new EnumConvert();
var query = from entity in BOMDataBase.TIS_TankDatas
join tank in BOMDataBase.MD_Tanks on entity.TankCode equals tank.Code
join area in BOMDataBase.MD_Areas on tank.AreaID equals area.ID
join material in BOMDataBase.MD_Materials on tank.MaterialID equals material.ID
// join tisMovementService in BOMDataBase.TIS_MovementServices on entity.TISMovementServiceID equals tisMovementService.ID
where entity.TimeStamp >= startDateTime && entity.TimeStamp <= endDateTime
select new TISTankDataModel()
{
ID = entity.ID,
TimeStamp = entity.TimeStamp,
TimeStampStr = entity.TimeStamp.ToString(),
TankID = tank.ID,
Tank = tank,
TankName = tank.Name,
AreaName = area.Name,
MaterialName = material.Name,
TankCode = entity.TankCode,
Level = entity.Level,
LevelStatus = entity.LevelStatus,
LevelStatusName = enumConvert.GetDescription(typeof(TankLevelStatus), entity.LevelStatus),
Pressure = entity.Pressure,
LiquidTemp = entity.LiquidTemp,
GasTemp = entity.GasTemp,
Density = entity.LiquidDensity,
IsPhysicalStockFail = entity.IsPhysicalStockFail,
VCF = entity.VCF,
GOV = entity.GOV,
GSV = entity.GSV,
// TISMovementServiceID = entity.TISMovementServiceID.Value,
// TISMovementService = tisMovementService,
Flowrate = entity.Flowrate,
RemainTime = entity.RemainTime
};
foreach (var item in query.ToList())
{
}
listTISTankDataModel = query.OrderByDescending(t => t.TimeStamp).ToList();
return listTISTankDataModel;
}
public List<SnapshotReportViewModel> GetSnapshotReportViewModel(int startIndex, int endIndex, DateTime startDateTime, DateTime endDateTime)
{
EnumConvert enumConvert = new EnumConvert();
var queryList = (from entity in BOMDataBase.TIS_TankDatas
join tank in BOMDataBase.MD_Tanks on entity.TankCode equals tank.Code
join area in BOMDataBase.MD_Areas on tank.AreaID equals area.ID
join material in BOMDataBase.MD_Materials on tank.MaterialID equals material.ID
// join tisMovementService in BOMDataBase.TIS_MovementServices on entity.TISMovementServiceID equals tisMovementService.ID
where entity.TimeStamp >= startDateTime && entity.TimeStamp <= endDateTime
select new SnapshotReportViewModel()
{
TankName = tank.Name,
MaterialName = material.Name,
Density15Deg = entity.LiquidDensity,
TimeStamp = entity.TimeStamp,
Level = entity.Level.Value,
LevelStatusName = enumConvert.GetDescription(typeof(TankLevelStatus), entity.LevelStatus),
LiquidTemp = entity.LiquidTemp.HasValue ? entity.LiquidTemp.Value : 0,
VOL_Gross = entity.GOV.HasValue ? entity.GOV.Value : 0,
VOL_Avail = entity.GOV.HasValue ? tank.MaxCapacityVol - entity.GOV.Value : tank.MaxCapacityVol,
VOL_Ullage = entity.GOV.HasValue ? tank.MinCapacityVol - entity.GOV.Value : tank.MinCapacityVol
}).Distinct().OrderByDescending(t => t.TimeStamp).Skip(startIndex).Take(endIndex).ToList();
int iSeq = 1;
foreach (var item in queryList)
item.No = iSeq++;
return queryList;
}
关于ling-sql的写法
最新推荐文章于 2024-01-27 14:28:40 发布