Reputation: 219
I have this entity :
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; }
}}
and I try to insert a new Snapshot into a database like this :
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);
}
}
Can you see any problem there? the snapshot I send to the XXX method look like this:
(Serialized in JSON ):
{"TrackId":2,"Track":null,"SnapshotNumber":2,"Data":"030405","Id":3}
any idea where is the problem?
thanks
Upvotes: 0
Views: 1857
Reputation: 26
The problem is Bltoolkit's LinQ insert method does not support a constant value: db.GetTable().Insert(() => s); s is a constant value.
Here are 02 solutions you can try:
Simply don't use the LinQ method:
db.Insert(s);
http://yfilonov.blogspot.com/2012/10/linq-warkaround-for-bltoolkit-insert.html
Upvotes: 1