Beispiel #1
0
        /// <summary>
        /// Creates a child entity
        /// </summary>
        /// <param name="parent">Parent entity</param>
        /// <param name="server">Aptify server connection</param>
        /// <param name="store">Entity storage</param>
        private AptifyEntity(AptifyEntity parent, AptifyServer server, EntityStore store)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            if (store == null)
            {
                throw new ArgumentNullException("store");
            }

            this.parent = parent;
            this.server = server;
            this.store  = store;

            // Get the entity that is mapped to this model instance
            this.table = server.Tables.GetTableMetadata(store.EntityObject);

            // Get the aptify generic entity and load its contents
            this.genericEntity = GetGenericEntity(server, parent, store, this.table.Entity);
            UpdateEntityContent( );

            // Load any child items
            if (store.Persister.HasCascades)
            {
                this.children = LoadChildEntities( ).ToArray( );
            }
        }
        /// <summary>
        /// Creates a new aptify store
        /// </summary>
        /// <param name="server">Server that this store is connecting</param>
        /// <param name="dialect">Dialect used to talk to the database</param>
        /// <param name="provider">Type of provider</param>
        /// <param name="handler">Event handler</param>
        public AptifyDataStore(AptifyServer server, IDialect dialect, Type provider, IEventHandler handler)
            : base(handler, dialect, provider, server.ConnectionString)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            this.server = server;

            // Setup our transaction factory
            Properties[ConfigEnvironment.TransactionStrategy] =
                typeof(AptifyTransactionFactory).AssemblyQualifiedName;

            // Handle the event to allow mapping
            ActiveRecordStarter.ModelsCreated += OnModelsCreated;
        }
Beispiel #3
0
        /// <summary>
        /// Loads an aptify entity
        /// </summary>
        private static AptifyGenericEntityBase GetGenericEntity(AptifyServer server, AptifyEntity parent, EntityStore store,
                                                                AptifyEntityMetadata metadata)
        {
            // Clean entities don't need to be loaded
            if (store.Status == EntityStatus.Clean && parent != null)
            {
                return(null);
            }

            Log.DebugFormat("Loading entity: '{0}'", metadata.Name);

            if (parent != null)
            {
                return(server.GetEntity(parent, metadata, store));
            }

            return(server.GetEntity(metadata, store));
        }
Beispiel #4
0
        private AptifyEntity(AptifyDataFieldBase field, AptifyServer server, EntityStore store)
        {
            if (!field.EmbeddedObjectExists)
            {
                throw new InvalidOperationException(field.Name + " is not an embedded object");
            }

            this.server = server;
            this.store  = store;

            // Get the entity that is mapped to this model instance
            this.table = server.Tables.GetTableMetadata(store.EntityObject);

            this.genericEntity = field.EmbeddedObject;
            UpdateEntityContent( );

            // Load any child items
            if (store.Persister.HasCascades)
            {
                this.children = LoadChildEntities( ).ToArray( );
            }

            //this.store.MarkAsPersisted( 0 );
        }
Beispiel #5
0
 /// <summary>
 /// Creates an instance of a generic entity
 /// </summary>
 /// <param name="server">Aptify server connection</param>
 /// <param name="store">Entity storage</param>
 public AptifyEntity(AptifyServer server, EntityStore store)
     : this(( AptifyEntity )null, server, store)
 {
 }