开发者

Subsonic generate table without primary key

I need to generate a table without primary key.开发者_如何学Python Its absolutely neccessary that the table dosen't have primary key. Please help.


It is absolutely necessary for the SubSonic that table contains primary key:)

The following is quoted from the SubSonic docs on conventions:

Primary Keys

If you want to use SubSonic to access your table, you need to have a Primary Key defined for your table. This is good practice in every case and we need it to do certain things with your table. If you don't have a Primary Key defined, your class won't be generated.

If you don't believe us, or if you think this is a silly convention - SubSonic isn't for you.


Is there any reason you cannot use something like sequences?

class Something {
     private static final SEQUENCE seq = getDBsequence()

     @id
     private final long id = seq.newNumber();

     private final String whateverData;
}

EDIT:The way I wrote this was kinda dumb because once you reboot the app. you'll get duplicate keys.. You should use a sequence provided by the DB. Sorry about that.


as Adam pointed out this isn't possible. To be honest I can't think of a situation (outside OLAP) where you can't have a PK. Or perhaps you're stuck in a legacy situation - I can dig that.

What you can do to get around it is, as you pointed out, use our querier tools and then you can send the results ToList<>. Updates should work the same way - not sure about inserts though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜