/// <summary> /// Returns ISessionFactory of a registered type /// </summary> public virtual ISessionFactory GetSessionFactory(Type type) { if (type == null) { throw new ArgumentNullException("type"); } type = GetNonProxyType(type); if (!Type2SessFactory.ContainsKey(type)) { throw new ActiveRecordException("No configuration for ActiveRecord found in the type hierarchy -> " + type.FullName); } var sessFactory = Type2SessFactory[type].SessionFactory; if (sessFactory != null) { return(sessFactory); } var cfg = GetConfiguration(type); sessFactory = cfg.BuildSessionFactory(); Type2SessFactory[type] = new SfHolder(cfg, sessFactory); return(sessFactory); }
///<summary> /// This method allows direct registration of Configuration ///</summary> public virtual void RegisterConfiguration(Configuration cfg, string name) { var sf = cfg.BuildSessionFactory(); var sfholder = new SfHolder(cfg, sf); foreach (var classMetadata in sf.GetAllClassMetadata()) { var entitytype = classMetadata.Value.GetMappedClass(EntityMode.Poco); if (Type2SessFactory.ContainsKey(entitytype)) { throw new ActiveRecordException("Type has already been registered -> " + entitytype.FullName); } Type2SessFactory.Add(entitytype, sfholder); } AR.RaiseSessionFactoryCreated(sf, cfg, name); }
///<summary> /// This method allows direct registration of Configuration ///</summary> public virtual void RegisterConfiguration(Configuration cfg, string name) { var sf = cfg.BuildSessionFactory(); var sfholder = new SfHolder(cfg, sf); foreach (var classMetadata in sf.GetAllClassMetadata()) { var entitytype = classMetadata.Value.GetMappedClass(EntityMode.Poco); if (Type2SessFactory.ContainsKey(entitytype)) throw new ActiveRecordException("Type has already been registered -> " + entitytype.FullName); Type2SessFactory.Add(entitytype, sfholder); } AR.RaiseSessionFactoryCreated(sf, cfg, name); }
/// <summary> /// Returns ISessionFactory of a registered type /// </summary> public virtual ISessionFactory GetSessionFactory(Type type) { if (type == null) throw new ArgumentNullException("type"); type = GetNonProxyType(type); if (!Type2SessFactory.ContainsKey(type)) { throw new ActiveRecordException("No configuration for ActiveRecord found in the type hierarchy -> " + type.FullName); } var sessFactory = Type2SessFactory[type].SessionFactory; if (sessFactory != null) { return sessFactory; } var cfg = GetConfiguration(type); sessFactory = cfg.BuildSessionFactory(); Type2SessFactory[type] = new SfHolder(cfg, sessFactory); return sessFactory; }