0
我無法編譯我的項目,以便在實體框架中的代碼優先遷移超過特定點。我正在讀取xml中的值來填充表格。我有以下代碼:未知CS1003錯誤
//EnrolmentProgramStartDate
var programQuery = from r in context.EnrolmentPrograms
select r;
var programList = programQuery.ToList<Entities.MetaData.Enrolment.EnrolmentProgram>();
resourceName = "LearnLogicElicos_WebApi.SeedData.MetaData.Enrolment.enrolment_program_start_date.xml";
stream = assembly.GetManifestResourceStream(resourceName);
xml = XDocument.Load(stream);
List<Entities.MetaData.Enrolment.EnrolmentProgramStartDate> enrolmentStartdates = new List<Entities.MetaData.Enrolment.EnrolmentProgramStartDate>();
foreach (var e in xml.Root.Elements("StartDate"))
{
DateTime.TryParse((string)e.Element("Start"), out var startDate);
enrolmentStartdates.Add(new Entities.MetaData.Enrolment.EnrolmentProgramStartDate()
{
PrgmCode = (string)e.Element("ProgramCode"),
StartDate = startDate
});
}
var programStartdateWithFk = (from t1 in enrolmentStartdates
join t2 in programList
on t1.PrgmCode equals t2.PrgmCode
select new Entities.MetaData.Enrolment.EnrolmentProgramStartDate
{
PrgmCode = t1.PrgmCode,
StartDate = t1.StartDate,
EnrolmentProgramFk = t2.PrgmPk
});
context.EnrolmentProgramStartDates.AddRange(programStartdateWithFk);
context.SaveChanges();
我收到以下錯誤在輸出窗口:Configuration.cs(179,71,179,80): error CS1003: Syntax error, ',' expected
,但我不是在錯誤列表中收到任何錯誤,我不能爲我的生活中看到失蹤,
。
的XML如下:
<?xml version="1.0" encoding="utf-8" ?>
<Starts>
<StartDate>
<ProgramCode>DEC25</ProgramCode>
<Start>2018,1,2</Start>
</StartDate>
<StartDate>
<ProgramCode>DEC15</ProgramCode>
<Start>2018,3,19</Start>
</StartDate>
<StartDate>
<ProgramCode>DEC10</ProgramCode>
<Start>2018,4,30</Start>
</StartDate>
<StartDate>
<ProgramCode>DEC5W</ProgramCode>
<Start>2018,6,4</Start>
</StartDate>
<StartDate>
<ProgramCode>DEC5R</ProgramCode>
<Start>2018,6,4</Start>
</StartDate>
<StartDate>
<ProgramCode>DEC5S</ProgramCode>
<Start>2018,6,4</Start>
</StartDate>
<StartDate>
<ProgramCode>DEC5L</ProgramCode>
<Start>2018,6,4</Start>
</StartDate>
<StartDate>
<ProgramCode>GE</ProgramCode>
<Start>2018,1,2</Start>
</StartDate>
<StartDate>
<ProgramCode>GE</ProgramCode>
<Start>2018,1,8</Start>
</StartDate>
<StartDate>
<ProgramCode>GE</ProgramCode>
<Start>2018,1,15</Start>
</StartDate>
<StartDate>
<ProgramCode>GE</ProgramCode>
<Start>2018,1,22</Start>
</StartDate>
<StartDate>
<ProgramCode>GE</ProgramCode>
<Start>2018,1,29</Start>
</StartDate>
<StartDate>
<ProgramCode>GE</ProgramCode>
<Start>2018,2,5</Start>
</StartDate>
<StartDate>
<ProgramCode>ITP</ProgramCode>
<Start>2018,1,2</Start>
</StartDate>
<StartDate>
<ProgramCode>ITP</ProgramCode>
<Start>2018,1,8</Start>
</StartDate>
<StartDate>
<ProgramCode>ITP</ProgramCode>
<Start>2018,1,15</Start>
</StartDate>
<StartDate>
<ProgramCode>ITP</ProgramCode>
<Start>2018,1,22</Start>
</StartDate>
<StartDate>
<ProgramCode>ITP</ProgramCode>
<Start>2018,1,29</Start>
</StartDate>
<StartDate>
<ProgramCode>ITP</ProgramCode>
<Start>2018,2,5</Start>
</StartDate>
</Starts>
可能有人請告訴我是:a)在缺少逗號,或b)什麼導致我得到這個錯誤,真正的問題是。
謝謝。
你是對的 - 壞標題。我改變了它試圖更好地反映我的問題。 – Ben