0
我有這樣的實體:bltoolkit插入數據到表
namespace Entities.dbo
{
[TableName("tbl_snapshot")]
public class Snapshot : AbstractEntity
{
[MapField("track")]
public int TrackId { get; set; }
[Association(CanBeNull = false, OtherKey = "id", ThisKey = "track")]
public Track Track { get; set; }
[MapField("snapshotnumber")]
public int SnapshotNumber { get; set; }
[MapField("data")]
public string Data { get; set; }
}}
,我嘗試插入一個新的快照變成這樣一個數據庫:
public static void XXX(Snapshot snapshot)
{
using (var db = new MyDbManager())
{
var s = new Snapshot
{
Id = snapshot.Id,
Data = snapshot.Data,
SnapshotNumber = snapshot.SnapshotNumber,
TrackId = snapshot.Track.Id
};
db.GetTable<Snapshot>().Insert(() => s);
}
}
你能看出什麼問題呢?我發送到XXX方法快照是這樣的:
(以JSON序列):
{"TrackId":2,"Track":null,"SnapshotNumber":2,"Data":"030405","Id":3}
任何想法,問題出在哪裏?
感謝
什麼問題?你有例外嗎?數據不正確? ... – Jensen 2013-03-17 12:55:17
也不例外,插入沒有進行,沒有插入任何東西 – 2013-03-17 13:00:01
哦,所以我最終發現異常,它說:由於對象的當前狀態,操作無效。 – 2013-03-17 17:04:24