TableInfo AutoRegisterType(Type type) { var ti = _owner.TablesInfo.FindByType(type); if (ti == null) { var name = _owner.Type2NameRegistry.FindNameByType(type) ?? _owner.RegisterType(type); ti = _owner.TablesInfo.LinkType2Name(type, name); } return(ti); }
TableInfo AutoRegisterType(Type type) { var ti = _owner.TablesInfo.FindByType(type); if (ti == null) { if (type.InheritsOrImplements(typeof(IEnumerable <>))) { throw new InvalidOperationException("Cannot store " + type.ToSimpleName() + " type to DB directly."); } var name = _owner.Type2NameRegistry.FindNameByType(type) ?? _owner.RegisterType(type); ti = _owner.TablesInfo.LinkType2Name(type, name); } return(ti); }
TableInfo AutoRegisterType(Type type, bool forceAutoRegistration = false) { var ti = _owner.TablesInfo.FindByType(type); if (ti == null) { if (type.InheritsOrImplements(typeof(IEnumerable <>))) { throw new InvalidOperationException("Cannot store " + type.ToSimpleName() + " type to DB directly."); } var name = _owner.Type2NameRegistry.FindNameByType(type); if (name == null) { if (!_owner.AutoRegisterTypes && !forceAutoRegistration) { throw new BTDBException($"Type {type.ToSimpleName()} is not registered."); } name = _owner.RegisterType(type); } ti = _owner.TablesInfo.LinkType2Name(type, name); } return(ti); }