Linq to MySql 为啥不设置主键列就不让我插入数据呢
1
2
3
|
Student stu =
new
Student() { Name =
"qqq"
, Age = (SByte)19 };
test.Student.InsertOnSubmit(stu);
test.SubmitChanges();
|
我用的是Dlinq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
string
connStr =
@"server=localhost;database=test;user=root;pwd=******;port=3306"
;
MySqlConnection con =
new
MySqlConnection(connStr);
Test test =
new
Test(con);
//var query = from s in test.Student
// select s;
//foreach (var item in query)
//{
// Console.WriteLine(item.Name);
//}
Student stu =
new
Student() { Name =
"qqq"
, Age = (SByte)19 };
test.Student.InsertOnSubmit(stu);
test.SubmitChanges();
//Teacher tea = new Teacher();
//tea.Name = "firefly";
//test.Teacher.InsertOnSubmit(tea);
//test.SubmitChanges();
Console.WriteLine();
|