How can I use Two or more DBContection in One Processing?

Nov 27, 2008 at 2:09 AM
In my Programe,I want use two differ dbcontection in one processing.but DbEntry appear support one connection in once?
How can I do it?thanks a lot!
Coordinator
Nov 27, 2008 at 5:48 AM
Every time you do a db stuff it will new a dbconnection like:

User u = User.New().Init("tom");
u.Save(); // first connection
u.Name = "jerry";
u.Save(); // 2nd connection
u.Delete(); // 3rd connection
u.FindBySql("select * from Users"); // 4th connection

Every time it will new the connection, open it, process and close it.

If you want use the same connection/trasaction, you can call;

DbEntry.UsingTrsaction
or
DbEntry.Context.UsingConnection

For your question, I don't think you need to do anything.
Nov 27, 2008 at 6:36 AM
可能我没表达清楚.我想在同一个进程里面两次调用DBEntry.可是我每次用的连接字符串都不一样.就是说,我想同时连接两个数据库,是面向不同连接的.比如:一个是数据库A,一个是数据库B.我想在同一进程中同时使用这两个数据库.谢谢!
Nov 27, 2008 at 6:39 AM
因为你的连接属性是用"DataBase"写死在app.config中的.如果我想同时有DataBase1...DataBaseN的连接.现在好象处理不了.
Coordinator
Nov 27, 2008 at 9:13 AM
So what you want is not multiple connection, it's multiple datasource:
http://www.codeplex.com/DbEntry/Wiki/View.aspx?title=Multiple%20data%20source&referringTitle=Home