开发者

Add the origin connectionString to Linq2Sql entities

I have a ASP.NET web application that use the same DataContextType to access several Databases with the same schema.

A problem I have is that I'd like to reference the origin Database of entities by adding to them a property (e.g. a ConnectionString property) and auto assign it on entity creation.

I though it could be done easily since i use PLINQO I already have a LinqEntityBase class but unfortunately there's no partial methods like OnMyEntityLoaded(MyEntity instance) in the DataContex开发者_运维问答t class...

The only method I see to do it is in the OnLoaded method of the entity but I would have to keep a ref to the current datacontext (or the connectionString) "somewhere" before and retrieve it after, it doesn't look ok at all (and if I work with multiple dbs in the same time it is just not possible).

Someone got an idea on how i could achieve this?


PLINQO is open source. If you need a partial method you could just add it to the CodeSmith template.

Also, you could submit a feature request for this on their forums or the GoogleCode issue tracker.
http://code.google.com/p/codesmith/issues/list

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜