[英]Linq Time(7) and TimeSpan Mapping
我正在嘗試在我的表中插入名為Test
的記錄,我正在使用LINQ技術:
問題是我的表中有一個time
列,類型為Time(7)
但是當我嘗試向表中插入數據時,我收到此錯誤:
Operand type clash: bigint is incompatible with time
這是我在SQL中的test
表設計:
我在C#中的表實現:
[Table(Name = "Test")]
class TableTest
{
private int _id;
[Column(IsPrimaryKey = true, Name = "id", Storage = "_id")]
public int id
{
get { return _id; }
set { _id = value; }
}
private TimeSpan _time;
[Column(Name = "time", Storage = "_time")]
public TimeSpan time
{
get { return _time; }
set { _time = value; }
}
}
在這里我嘗試插入我的記錄:
DataContext dc = new DataContext(@"Data Source=.;Initial Catalog=DBTest;Integrated Security=True");
private void button1_Click(object sender, EventArgs e)
{
TableTest t = new TableTest();
t.id = 1;
t.time = new TimeSpan(7, 30, 0);
Table<TableTest> t_insert = dc.GetTable<TableTest>();
t_insert.InsertOnSubmit(t);
dc.SubmitChanges(); // error Here !!!!!
}
我搜索過的每一個地方,我發現的只是為了映射Time()
sql類型我應該使用TimeSpan
,請告訴我我做錯了什么! 謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.