Ejemplo n.º 1
0
        /// <summary>
        /// Utility method to copy all unique constraints of a class
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        private static void CopyUniqueConstraints(UniqueConstraintCollection source, ClassDefinition target)
        {
            if (source.Count == 0)
            {
                return;
            }

            var props = target.Properties;

            foreach (UniqueConstraint uniq in source)
            {
                var ucs = new UniqueConstraint();
                foreach (DataPropertyDefinition dp in uniq.Properties)
                {
                    if (props.Contains(dp.Name))
                    {
                        var prop = props[dp.Name];
                        if (prop.PropertyType == PropertyType.PropertyType_DataProperty)
                        {
                            ucs.Properties.Add((DataPropertyDefinition)prop);
                        }
                    }
                }
                target.UniqueConstraints.Add(ucs);
            }
        }
Ejemplo n.º 2
0
 private static string GetUniqueConstraintString(UniqueConstraintCollection constraints)
 {
     if (constraints.Count == 0)
     {
         return("(none)");
     }
     else
     {
         List <string> ucstr = new List <string>();
         foreach (UniqueConstraint uc in constraints)
         {
             List <string> str = new List <string>();
             foreach (DataPropertyDefinition dp in uc.Properties)
             {
                 str.Add(dp.Name);
             }
             ucstr.Add(" - (" + string.Join(",", str.ToArray()) + ")");
         }
         return("\n" + string.Join("\n", ucstr.ToArray()));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Utility method to copy all unique constraints of a class
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        private static void CopyUniqueConstraints(UniqueConstraintCollection source, ClassDefinition target)
        {
            if (source.Count == 0)
                return;

            var props = target.Properties;
            foreach (UniqueConstraint uniq in source)
            {
                var ucs = new UniqueConstraint();
                foreach (DataPropertyDefinition dp in uniq.Properties)
                {
                    if (props.Contains(dp.Name))
                    {
                        var prop = props[dp.Name];
                        if (prop.PropertyType == PropertyType.PropertyType_DataProperty)
                            ucs.Properties.Add((DataPropertyDefinition)prop);
                    }
                }
                target.UniqueConstraints.Add(ucs);
            }
        }
 private static string GetUniqueConstraintString(UniqueConstraintCollection constraints)
 {
     if (constraints.Count == 0)
         return "(none)";
     else
     {
         List<string> ucstr = new List<string>();
         foreach (UniqueConstraint uc in constraints)
         {
             List<string> str = new List<string>();
             foreach (DataPropertyDefinition dp in uc.Properties)
             {
                 str.Add(dp.Name);
             }
             ucstr.Add(" - (" + string.Join(",", str.ToArray()) + ")");
         }
         return "\n" + string.Join("\n", ucstr.ToArray());
     }
 }