使用此代码,我的数据库中没有任何更改。当运行上面的代码时,不再创建新的条目,也不再更新条目。
public void UpdateCallback(callback cb_)
{
callback call = context.callbacks.Single(c => c.callbackID == cb_.callbackID);
//call.callbackID = cb_.callbackID;
call.status = cb_.status;
call.contactName = cb_.contactName;
call.company = cb_.company;
call.phone = cb_.phone;
call.calledDate = cb_.calledDate;
call.callback1 = cb_.callback1;
call.notes = cb_.notes;
try
{
context.SubmitChanges();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}发布于 2009-04-24 07:15:44
发布于 2009-04-24 06:59:19
没有什么能立即引起我的注意。我发现使用DataContext的Log属性来查看生成的SQL非常有用。
请参阅http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.log.aspx
然后,您可以在调试时使用类似以下代码的代码将SQL输出到Visual Studio Debug窗口。
/// <summary>
/// Implementation of a <see cref="TextWriter"/> that outputs to the debug window
/// </summary>
public class DebugTextWriter : TextWriter
{
public override void Write(char[] buffer, int index, int count)
{
System.Diagnostics.Debug.Write(new string(buffer, index, count));
}
public override void Write(string value)
{
System.Diagnostics.Debug.Write(value);
}
public override Encoding Encoding
{
get { return System.Text.Encoding.Default; }
}
}https://stackoverflow.com/questions/784677
复制相似问题