The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Set Default connection based on namespace

Last post 08-14-2008, 8:15 AM by Mike.Griffin. 1 replies.
Sort Posts: Previous Next
  •  08-12-2008, 9:27 PM 10707

    Set Default connection based on namespace

    I have two different databases I am accessing within my program.  Each database has a different schema and thus a different set of generated classes.  Database A should use the default connection in the entity spaces configuration and Database B should use the second connection defined in the entity spaces configuration.  It seems that the only way to accomplish this is to continually set the Connection.Name property after instantiating an entity, collection or query class.  It would be nice if the default connection for a entity, collection or query class could be set based on namespace in the configuration.  For example, the classes used for database B are in namespace ABC and the classes for database A are in namespace XYZ and via configuration I  specifiy <namespacerule default="connection1" namespace="ABC"/><namespacerule default="connection2" namespace="XYZ"/>.

     My current workaround is to use the QueryBase, CollectionBase and EntityBase and implement the defaulting within the default constructor for example:

    Code:
    public QueryBase()
    {
      es.Connection.Name = GetDefaultConnection(this.GetType().Namespace)
    }
  •  08-14-2008, 8:15 AM 10747 in reply to 10707

    Re: Set Default connection based on namespace

    Your post did not go un-noticed. We spoke about this last night about sneaking it into our next maintenance release.
    EntitySpaces | Twitter | BLOG | Please honor our Software License
View as RSS news feed in XML