コード例 #1
0
        protected override void OnDynamicEntityRegistration(DynamicEntityDefinition definition, bool ensureCompatibility)
        {
            string name = definition.EntityName;

            if (!TableExists(name))
            {
                var fields = new List <Field>();

                foreach (var field in definition.Fields)
                {
                    if (ReservedWords.Contains(field.FieldName, StringComparer.InvariantCultureIgnoreCase))
                    {
                        throw new ReservedWordException(field.FieldName);
                    }

                    fields.Add(FieldFactory.GetFieldForAttribute(field, definition.EntityAttribute.KeyScheme));
                }

                m_session.Data.CreateTable(name, name, fields);
            }
            else
            {
                ValidateTable(definition);
            }
        }
コード例 #2
0
        private void ValidateTable(IEntityInfo entity)
        {
            if (!TableExists(entity.EntityAttribute.NameInStore))
            {
                CreateTable(entity);
                return;
            }

            var fields = new List <Field>();

            foreach (var field in entity.Fields)
            {
                if (ReservedWords.Contains(field.FieldName, StringComparer.InvariantCultureIgnoreCase))
                {
                    throw new ReservedWordException(field.FieldName);
                }

                fields.Add(FieldFactory.GetFieldForAttribute(field, entity.EntityAttribute.KeyScheme));
            }

            try
            {
                m_session.Data.UpdateTable(entity.EntityName, fields);
            }
            catch (InvalidSessionException)
            {
                m_session.Reconnect();
                m_session.Data.UpdateTable(entity.EntityName, fields);
            }
        }
コード例 #3
0
        private void CreateTable(IEntityInfo entity)
        {
            var fields = new List <Field>();

            foreach (var field in entity.Fields)
            {
                if (ReservedWords.Contains(field.FieldName, StringComparer.InvariantCultureIgnoreCase))
                {
                    throw new ReservedWordException(field.FieldName);
                }

                fields.Add(FieldFactory.GetFieldForAttribute(field, entity.EntityAttribute.KeyScheme));
            }

            var name = entity.EntityAttribute.NameInStore ?? entity.EntityName;

            m_session.Data.CreateTable(name, name, fields);
        }