Exemplo n.º 1
0
        public static void DefineOrUpdateDeviceProperty(device_propertys dp)
        {
            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                device_propertys existing_dp = db.device_propertys.FirstOrDefault(d => d.name == dp.name);

                if (existing_dp == null)
                {
                    db.device_propertys.AddObject(dp);
                }
                else
                {
                    existing_dp.friendly_name = dp.friendly_name;
                    existing_dp.value_data_type = dp.value_data_type;
                    existing_dp.default_value = dp.default_value;

                    foreach (var option in db.device_property_options.Where(p => p.device_property_id == existing_dp.id).ToArray())
                    {
                        db.DeleteObject(option);
                    }

                    foreach (device_property_options dpo in dp.device_property_options)
                        existing_dp.device_property_options.Add(new device_property_options { name = dpo.name });

                }
                db.SaveChanges();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the device_propertys EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTodevice_propertys(device_propertys device_propertys)
 {
     base.AddObject("device_propertys", device_propertys);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new device_propertys object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="friendly_name">Initial value of the friendly_name property.</param>
 /// <param name="name">Initial value of the name property.</param>
 /// <param name="default_value">Initial value of the default_value property.</param>
 /// <param name="value_data_type">Initial value of the value_data_type property.</param>
 public static device_propertys Createdevice_propertys(global::System.Int64 id, global::System.String friendly_name, global::System.String name, global::System.String default_value, global::System.Int64 value_data_type)
 {
     device_propertys device_propertys = new device_propertys();
     device_propertys.id = id;
     device_propertys.friendly_name = friendly_name;
     device_propertys.name = name;
     device_propertys.default_value = default_value;
     device_propertys.value_data_type = value_data_type;
     return device_propertys;
 }