Exemple #1
0
 public IEnumerable <PropertyDefinition> GetProperties()
 {
     if (_baseEntity != null)
     {
         return
             (OwnProperties
              .Union(_baseEntity.GetProperties().Select(item => item.Clone(this)),
                     new EqualityComparer <PropertyDefinition, string>(item => item.Name))
              .OrderBy(item => OwnProperties.Any(p => p.Identifier == item.Identifier) ? 2 : 1));
     }
     return(OwnProperties);
 }
Exemple #2
0
        private void CheckProperty(PropertyDefinition pe)
        {
            if (string.IsNullOrEmpty(pe.Name))
            {
                throw new ArgumentException(string.Format("Property {0} has no Name", pe.Identifier));
            }

            if (string.IsNullOrEmpty(pe.PropertyAlias))
            {
                throw new ArgumentException(string.Format("Property {0} has no PropertyAlias", pe.Identifier));
            }

            if (OwnProperties.Any(item => item.PropertyAlias == pe.PropertyAlias))
            {
                string t = pe.Entity == null?"unknown":pe.Entity.Identifier;

                throw new ArgumentException(string.Format(
                                                "Property with alias {0} already exists in type {1}. Added from {2}",
                                                pe.PropertyAlias, Identifier, t));
            }

            if (OwnProperties.Any(item => item.Name == pe.Name))
            {
                string t = pe.Entity == null ? "unknown" : pe.Entity.Identifier;

                throw new ArgumentException(string.Format(
                                                "Property with name {0} already exists in type {1}. Added from {2}",
                                                pe.Name, Identifier, t));
            }

            if (Model != null && pe.PropertyType != null && !Model.GetTypes().Any(item => item.Identifier == pe.PropertyType.Identifier))
            {
                throw new ArgumentException(string.Format("Property {0} has type {1} which is not found in Model.Types collection", pe.PropertyAlias, pe.PropertyType.Identifier));
            }

            if (pe.SourceFragment != null && !GetSourceFragments().Any(item => item.Identifier == pe.SourceFragment.Identifier))
            {
                throw new ArgumentException(string.Format("Property {0} has SourceFragment {1} which is not found in SourceFragments collection", pe.PropertyAlias, pe.SourceFragment.Identifier));
            }
        }
Exemple #3
0
        public bool NeedOwnSchema()
        {
            if (OwnProperties.Any(item => !item.Disabled && item.HasMapping) ||
                Model.GetActiveRelations().OfType <RelationDefinition>()
                .Any(item => item.Left.Entity.Identifier == Identifier ||
                     item.Right.Entity.Identifier == Identifier) ||
                Model.GetActiveRelations().OfType <SelfRelationDefinition>()
                .Any(item => item.Entity.Identifier == Identifier))
            {
                return(true);
            }

            foreach (SourceFragmentRefDefinition tbl in OwnSourceFragments)
            {
                if (tbl.Replaces != null)
                {
                    return(true);
                }

                if (tbl.AnchorTable != null)
                {
                    return(true);
                }

                foreach (SourceFragmentRefDefinition.Condition condition in tbl.Conditions)
                {
                    if (!string.IsNullOrEmpty(condition.LeftColumn) &&
                        !string.IsNullOrEmpty(condition.RightConstant))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }