我有一个spreedsheet和数据,但问题是我的数据是错误的,是它的格式不符合要求,需要一些帮助。这是我的应用逻辑。sql查询是针对我的记录列表,从数据库中查询1个数据库中的3个不同表,控制器和模型是针对我的逻辑,以根据我的要求生成以下图像。
// SQL query
SELECT TOP (1000) [WeekId]
,[WeekNum]
,[Year]
,[CreatedDate]
,[CreatedBy]
,[ModifiedDate]
,[ModifiedBy]
,[InActive]
FROM [ProductionManagement].[Schedule].[Week]
SELECT TOP (1000) [ProductionDayId]
,[WeekId]
,[ProductionDate]
,[DayOfWeek]
,[CreatedDate]
,[CreatedBy]
,[ModifiedDate]
,[ModifiedBy]
,[InActive]
FROM [ProductionManagement].[Schedule].[ProductionDay]
SELECT TOP (1000) [ModelId]
,[Name]
,[Code]
,[CreatedDate]
,[CreatedBy]
,[ModifiedDate]
,[ModifiedBy]
,[InActive]
FROM [ProductionManagement].[Schedule].[Model]
// controller
public IList<ExtractionViewModel> GetExtractionViewModels()
{
var db = new ProductionManagementEntities();
var scheduleList = (from p in db.ProductionDays
from m in db.Models
join w in db.Weeks on p.WeekId equals w.WeekId
orderby w.Year ascending
orderby m.Name descending
where(m.InActive == true)
select new ExtractionViewModel
{
Year = w.Year,
Week = w.WeekNum,
Day = p.ProductionDate,
VW250 = m.Name,
VW270 = m.Name,
VW2502PA = m.Name,
VW270PA = m.Name
}).ToList();
return scheduleList;
}
public class ExtractionViewModel
{
public string Year { get; set; }
public int Week { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0;yyyy-MM-dd}", ApplyFormatInEditMode =false)]
public DateTime Day { get; set; }
public string VW250 { get; set; }
public string VW270 { get; set; }
public string VW2502PA { get; set; }
public string VW270PA { get; set; }
}
1条答案
按热度按时间cyvaqqii1#
尝试以下操作: