[英]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.