我有这个实体:
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}
知道问题出在哪里吗?
谢谢