이것은 작성한 코드입니다. Quick Watch에서 볼 때 모든 것이 정상적으로 작동하지만 데이터베이스가 업데이트되지 않습니다. updatedata.aspx.cs 데이터베이스에있는 기존 라벨을 찾아 새 레이블로 교체하여 라벨을 업데이트하고 내가 여기서 뭐하는 거지데이터를 데이터베이스로 업데이트 할 수 없습니다. 코드가 정상적으로 작동하는 경우에도
using (var dc = new TrainingEntities())
{
var oldData = dc.tr_schools.ToList();
var newData = oldData.Select(o => new tr_schools()
{
banner = o.banner,
imageOff = o.imageOff,
imageOn = o.imageOn,
name = o.name,
schoolUID = o.schoolUID,
sequence = o.sequence,
title = o.title,
tr_modulesToSchools = o.tr_modulesToSchools,
type = o.type
}).ToList();
newData[0].name = newData[0].name + "XYZ";
newData[1].name = newData[1].name + "ABC";
var contents = dc.tr_Content.ToList();
foreach (var entryold in oldData)
{
foreach (var entrynew in newData)
{
if (entrynew.schoolUID == entryold.schoolUID && entrynew.name != entryold.name)
{
string filter = "-Courses- School " + entryold.name + " Banner Image";
var schoolContents = contents.Where(p => p.Label.Contains(filter));
foreach (var schoolContent in schoolContents)
{
schoolContent.Label = schoolContent.Label.Replace(entryold.name, entrynew.name);
}
}
}
}
dc.SaveChanges();
IN
.
내 연결 문자열
:<connectionStrings>
<add name="TrainingConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=ABCD;User ID=***;Password=*****;" providerName="System.Data.SqlClient" />
<add name="TrainingEntities" connectionString="metadata=res://*/Models.DAL.TrainingEntities.csdl|res://*/Models.DAL.TrainingEntities.ssdl|res://*/Models.DAL.TrainingEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;initial catalog=ABCD;user id=***;password=*****;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
아니, 난이 아닙니다 .... –