In my mygeneration Study Notes (1): Use mygeneration to generate stored procedures and data access layer code, I mentioned using internal string _ raw = projectname. properties. settings. default. connectionstring; this statement is used to initialize the database connection string. Now, you can only use this method in a single database system.ProgramIf the set (assembly) requires multiple databases, you need to find another method :)
One method is the original method I mentioned at the beginning: "manually assign a value to the connectionstring attribute in the application, but in this case, assign a value to the connectionstring value after each business entity completes the new operation ". It seems that this method is not great. Imagine that when building an application with a n-layer architecture, the developers at the upper layer of the concrete class also need to know which database the concrete class currently operates on, which table in the corresponding database is depressing...
Can I encapsulate database connection operations? The answer is yes! Solution: Set the database connection string in the concrete class constructor generated by doodad. For example:
public class employee: _ employee
{< br> public employee ()
{< br> This. connectionstring = properties. settings. default. strconnectto * dB;
}< br> // other members
}< br> in this way, the developers at the upper layer of the concrete class do not have to worry about the databases at the bottom layer and the databases to be operated by the concreteclass :)