Subsonic 3.0.0.4 mysql 活动记录模板不返回最后插入的 id
重现错误的步骤:
CREATE TABLE person ( person_id int(11) NOT NULL AUTO_INCRMENT,firstname varchar(20) DEFAULT NULL,lastname varchar(20) DEFAULT NULL,age int(11) DEFAULT '0',主键 (person_id) ) ENGINE=InnoDB AUTO_INCRMENT=36 DEFAULT CHARSET= latin1
INSERT INTO person(名字,姓氏,年龄) VALUES ('myname',NULL,NULL) ;SELECT LAST_INSERT_ID() as newid
Person personObject = new Person();
personObject.Firstname= "myname";
personObject.Add();
Response.Write(personObject.PersonId);
输出为“0”
Steps to reproduce error:
CREATE TABLE person (
person_id int(11) NOT NULL AUTO_INCREMENT, firstname varchar(20) DEFAULT NULL, lastname varchar(20) DEFAULT NULL, age int(11) DEFAULT '0', PRIMARY KEY (person_id) ) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=latin1
INSERT INTO person(firstname,lastname,age)
VALUES ('myname',NULL,NULL) ;SELECT LAST_INSERT_ID() as newid
Person personObject = new Person();
personObject.Firstname= "myname";
personObject.Add();
Response.Write(personObject.PersonId);
output is"0'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是一个错误,而是一个错误,如果您更改列和表的命名约定,则可能会发生 ->帕斯卡案例。默认情况下,列/表名称按照 MySQL 数据库中定义的方式进行复制。这使得这个丑陋的
原始
我喜欢发生的事情
在更改默认模板以使用 SubSonic 的变形器类生成以下名称后,SubSonic 核心将出现两个(〜3,现在不记得)主要问题。
必须更改 UPDATES/INSERTS 所需属性的反射
示例:
执行插入时,列名应返回到其原始属性
例子:
This not a bug but rather an error that is likely to happen if you change the naming convention of columns and tables -> ToPascalCase. By default a column/table name is copied the way it is defined on the MySQL database. Which makes this ugly
Original
What I like to happen
There will be two(~3, can't remember now) major issues to the SubSonic core after changing the default template to generate the following names using SubSonic's inflector class.
reflection for properties that are required for UPDATES/INSERTS must be changed
example:
column names should be returned to its original property when doing inserts
example: