Ejemplo n.º 1
0
 internal EditDatabaseScope(LocalDbManager dbManager)
     : base(dbManager)
 {
     Drop  = new DropCommand(this);
     Scope = dbManager;
 }
Ejemplo n.º 2
0
		internal EditDatabaseScope(LocalDbManager dbManager) 
			: base(dbManager)
		{
			Drop = new DropCommand(this);
			Scope = dbManager;
		}
Ejemplo n.º 3
0
        /// <summary>
        ///     Internal Usage
        /// </summary>
        /// <param name="type"></param>
        /// <param name="keyGenerator"></param>
        /// <param name="config"></param>
        /// <param name="useOrignalObjectInMemory"></param>
        private void Init(Type type,
                          ILocalDbPrimaryKeyConstraint keyGenerator,
                          DbConfig config,
                          bool useOrignalObjectInMemory)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (_config != null)
            {
                throw new InvalidOperationException("Multibe calls of Init are not supported");
            }

            _keepOriginalObject = useOrignalObjectInMemory;
            _config             = config;
            _databaseDatabase   = LocalDbManager.Scope;
            if (_databaseDatabase == null)
            {
                throw new NotSupportedException("Please define a new DatabaseScope that allows to seperate" +
                                                " multibe tables of the same type in the same Application");
            }

            _typeInfo = _config.GetOrCreateClassInfoCache(type);
            if (_typeInfo.PrimaryKeyProperty == null)
            {
                throw new NotSupportedException(string.Format("Entitys without any PrimaryKey are not supported. " +
                                                              "Type: '{0}'", type.Name));
            }

            TypeKeyInfo = _config.GetOrCreateClassInfoCache(_typeInfo.PrimaryKeyProperty.PropertyType);

            if (TypeKeyInfo == null)
            {
                throw new NotSupportedException(string.Format("Entitys without any PrimaryKey are not supported. " +
                                                              "Type: '{0}'", type.Name));
            }

            if (!TypeKeyInfo.Type.IsValueType)
            {
                throw new NotSupportedException(string.Format("Entitys without any PrimaryKey that is of " +
                                                              "type of any value-type cannot be used. Type: '{0}'", type.Name));
            }

            if (!_keepOriginalObject)
            {
                if (!TypeInfo.FullFactory)
                {
                    TypeInfo.CreateFactory(config);
                    if (!TypeInfo.FullFactory)
                    {
                        throw new NotSupportedException(string.Format("The given type did not provide a Full ado.net constructor " +
                                                                      "Type: '{0}'", TypeInfo));
                    }
                }
            }

            ILocalDbPrimaryKeyConstraint primaryKeyConstraint;

            if (keyGenerator != null)
            {
                primaryKeyConstraint = keyGenerator;
            }
            else
            {
                ILocalDbPrimaryKeyConstraint defaultKeyGen;
                if (LocalDbManager.DefaultPkProvider.TryGetValue(TypeKeyInfo.Type, out defaultKeyGen))
                {
                    primaryKeyConstraint = defaultKeyGen.Clone();
                }
                else
                {
                    throw new NotSupportedException(
                              string.Format(
                                  "You must specify ether an Primary key that is of one of this types " +
                                  "({1}) " +
                                  "or invoke the ctor with an proper keyGenerator. " +
                                  "Type: '{0}'",
                                  type.Name,
                                  LocalDbManager
                                  .DefaultPkProvider
                                  .Keys
                                  .Select(f => f.Name)
                                  .Aggregate((e, f) => e + "," + f)));
                }
            }

            Constraints = new ConstraintCollection <TEntity>(this, primaryKeyConstraint);
            _triggers   = new TriggerForTableCollection <TEntity>(this);
            _indexes    = new IndexCollection <TEntity>();
            Base        = new ConcurrentDictionary <object, TEntity>();
            _databaseDatabase.AddTable(this);
            _databaseDatabase.SetupDone += DatabaseDatabaseOnSetupDone;
        }
Ejemplo n.º 4
0
 internal DataContent(LocalDbManager instance)
 {
     _instance = instance;
 }
Ejemplo n.º 5
0
		internal DataContent(LocalDbManager instance)
		{
			_instance = instance;
		}