Example #1
0
        private static compositeid GetCompositeIDWithProperties(ITable table, Entity entity)
        {
            compositeid cId = new compositeid();
            foreach (var property in entity.Key.Properties)
            {
                IColumn mappedColumn = property.MappedColumn();
                if (mappedColumn == null)
                    continue;

                cId.AddKeyProperty(new keyproperty
                                    {
                                        column1 = mappedColumn.Name.BackTick(),
                                        name = property.Name
                                    });
            }
            return cId;
        }
Example #2
0
 private void ProcessCompositeKey(hibernatemapping hm, @class hClass, Entity newEntity, Mapping mapping, ParseResults parseResults, compositeid hCompId)
 {
     foreach (var prop in hCompId.KeyProperties())
     {
         var idProperty = CreateProperty(newEntity, mapping, prop);
         SetPropertyInfoFromParsedCode(idProperty, parseResults, hm.@namespace, mapping.FromTable.Schema, hClass.name);
         idProperty.IsKeyProperty = true;
     }
 }
Example #3
0
        private static compositeid GetCompositeIDWithComponent(Component component)
        {
            compositeid cId = new compositeid();
            cId.@class = component.Specification.Name;
            cId.name = component.Name;

            foreach (var property in component.Properties)
            {
                IColumn mappedColumn = property.MappedColumn();
                if (mappedColumn == null)
                    continue;

                cId.AddKeyProperty(new keyproperty
                {
                    column1 = mappedColumn.Name.BackTick(),
                    name = property.PropertyName
                });
            }
            return cId;
        }
Example #4
0
        private bool ProcessComponentKey(compositeid hCompId, Entity newEntity, ITable mappedTable, Dictionary<Class, ComponentSpecification> specifications, string hmNamespace, ParseResults parseResults)
        {
            var possibleClasses = GetPossibleClasses(hCompId.@class, hmNamespace, mappedTable.Schema, parseResults);

            if (possibleClasses.Count == 0) return false;

            ComponentSpecification spec = null;

            foreach (var possibleClass in possibleClasses)
            {
                spec = specifications.GetValueOrDefault(possibleClass);

                if (spec != null)
                    break;
            }
            bool createProperties = false;

            if (spec == null)
            {
                // Create a new spec from these.
                spec = new ComponentSpecificationImpl(GetShortClassName(hCompId.@class));
                newEntity.EntitySet.AddComponentSpecification(spec);
                createProperties = true;
            }

            Component component = spec.CreateImplementedComponentFor(newEntity, hCompId.name);
            newEntity.Key.Component = component;

            var mapping = new ComponentMappingImpl();

            foreach (var prop in hCompId.KeyProperties())
            {
                if (createProperties)
                {

                    ComponentProperty idProperty = new ComponentPropertyImpl(prop.name);
                    idProperty.Type = prop.type1;
                    idProperty.ValidationOptions.MaximumLength = prop.length.As<int>();
                    SetPropertyInfoFromParsedCode(possibleClasses, idProperty);

                    spec.AddProperty(idProperty);
                }

                var compProperty = component.GetProperty(prop.name);
                var column = mappedTable.GetColumn(prop.column1.UnBackTick());
                if (column == null)
                {
                    // Create the column
                    column = entityProcessor.CreateColumn(compProperty.RepresentedProperty);
                    mapping.FromTable.AddColumn(column);
                }

                mapping.AddPropertyAndColumn(compProperty, column);
            }
            newEntity.EntitySet.MappingSet.AddMapping(mapping);

            return true;
        }