开发者

SubSonic 3 Using Insert.Into<> without having to specify column names and values?

I'm just starting to use SubSonic 3 and I'm struggling with a basic insert operation.

I would like to insert a new row into a table with all columns and values as specified by an entity object. However the only examples I can find look like you have to specify each column and value, which to me isn't a big step up from doing the raw SQL insert!

myDB.Insert.Into<MyTable>(m => m.Col1, m=m.Col2, etc).Values(col1Val, col2Val,...)

I'm not using the ActiveRecord template which I know from 2.x can d开发者_Go百科o this and there doesn't seem to a Repository.tt template with the version I downloaded (SubSonic.Core 3.0.0.3).

So is this possible?

Is there a Repository.tt template available for v3.0.0.3?

Thanks,

Canice.


You will not need a Repository.tt all you need is to instantiate an instance of SimpleRepository and call the Insert method which takes a type as generic argument and instance which is persisted.

You can take a look at the simple repository tests on github: https://github.com/subsonic/SubSonic-3.0/blob/master/SubSonic.Tests/Repositories/SimpleRepositoryTests.cs

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜