コード例 #1
0
        private void ValidateConfigurationAggregate(Configuration cfg)
        {
            if (Configurations.Any(c => c.Group == cfg.Group && c.Name == cfg.Name))
            {
                throw new ApplicationException("DUP_CONFIGURATION");
            }

            // More validations...
        }
コード例 #2
0
        /// <summary>
        /// Create a set of configurations
        /// *** SaveChanges is required to be called ***
        /// </summary>
        /// <param name="group">A group</param>
        /// <param name="names">Names, must be unique within the group</param>
        /// <param name="values1">A value, cannot be null</param>
        /// <param name="values2">A another value, can be null</param>
        /// <param name="values3">A the other value, can be null</param>
        /// <param name="descs">A description</param>
        /// <returns>Newly created configurations</returns>
        public static Configuration[] CreateConfigurationSet(TransactionModelContainer container, 
            string createBy, string group, string[] names,
            string[] values1, string[] values2, string[] values3, string[] descs)
        {
            if (string.IsNullOrEmpty(group))
            {
                throw new ArgumentException("NULL_OR_EMPTY_GROUP");
            }

            if (names == null || names.Length <= 0)
            {
                throw new ArgumentException("NULL_OR_EMPTY_NAMES");
            }

            if (values1 == null || values1.Length <= 0)
            {
                throw new ArgumentException("NULL_OR_EMPTY_VALUES1");
            }

            if (names.Length != values1.Length)
            {
                throw new ArgumentException("NUMBER_OF_NAMES_AND_VALUES1_NOT_MATCH");
            }

            Configuration[] configurations = new Configuration[names.Length];

            for (int i = 0; i < names.Length; i++)
            {
                configurations[i] = new Configuration(createBy, group, names[i], values1[i]);
                configurations[i].Value2 = values2 != null && values2.Length >= (i + 1) ? values2[i] : null;
                configurations[i].Value3 = values3 != null && values3.Length >= (i + 1) ? values3[i] : null;
                configurations[i].Description = descs != null && descs.Length >= (i + 1) ? descs[i] : null;
                container.Configurations.AddObject(configurations[i]);
            }

            return configurations;
        }
コード例 #3
0
 /// <summary>
 /// Create a new Configuration object.
 /// </summary>
 /// <param name="group">Initial value of the Group property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="value1">Initial value of the Value1 property.</param>
 /// <param name="version">Initial value of the Version property.</param>
 /// <param name="createDate">Initial value of the CreateDate property.</param>
 /// <param name="createBy">Initial value of the CreateBy property.</param>
 /// <param name="updateDate">Initial value of the UpdateDate property.</param>
 /// <param name="updateBy">Initial value of the UpdateBy property.</param>
 public static Configuration CreateConfiguration(global::System.String group, global::System.String name, global::System.String value1, global::System.Byte[] version, global::System.DateTime createDate, global::System.String createBy, global::System.DateTime updateDate, global::System.String updateBy)
 {
     Configuration configuration = new Configuration();
     configuration.Group = group;
     configuration.Name = name;
     configuration.Value1 = value1;
     configuration.Version = version;
     configuration.CreateDate = createDate;
     configuration.CreateBy = createBy;
     configuration.UpdateDate = updateDate;
     configuration.UpdateBy = updateBy;
     return configuration;
 }
コード例 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Configurations EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToConfigurations(Configuration configuration)
 {
     base.AddObject("Configurations", configuration);
 }