本文整理汇总了C#中DeviceHive.Data.EF.DeviceHiveContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# DeviceHiveContext.SaveChanges方法的具体用法?C# DeviceHiveContext.SaveChanges怎么用?C# DeviceHiveContext.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceHive.Data.EF.DeviceHiveContext
的用法示例。
在下文中一共展示了DeviceHiveContext.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
public void Save(DeviceClass deviceClass)
{
if (deviceClass == null)
throw new ArgumentNullException("deviceClass");
using (var context = new DeviceHiveContext())
{
context.DeviceClasses.Add(deviceClass);
if (deviceClass.ID > 0)
{
context.Entry(deviceClass).State = EntityState.Modified;
foreach (var equipment in deviceClass.Equipment.Where(e => e.ID > 0))
{
context.Entry(equipment).State = EntityState.Modified;
}
foreach (var equipment in context.Equipments.Where(e => e.DeviceClassID == deviceClass.ID))
{
if (context.Entry(equipment).State == EntityState.Unchanged)
context.Equipments.Remove(equipment);
}
}
context.SaveChanges();
}
}
示例2: Save
public void Save(AccessKey accessKey)
{
if (accessKey == null)
throw new ArgumentNullException("accessKey");
using (var context = new DeviceHiveContext())
{
context.AccessKeys.Add(accessKey);
if (accessKey.ID > 0)
{
context.Entry(accessKey).State = EntityState.Modified;
foreach (var permission in accessKey.Permissions.Where(e => e.ID > 0))
{
context.Entry(permission).State = EntityState.Modified;
}
foreach (var permission in context.AccessKeyPermissions.Where(e => e.AccessKeyID == accessKey.ID))
{
if (context.Entry(permission).State == EntityState.Unchanged)
context.AccessKeyPermissions.Remove(permission);
}
}
context.SaveChanges();
}
}
示例3: Delete
public void Delete(int id)
{
using (var context = new DeviceHiveContext())
{
var command = context.DeviceCommands.Find(id);
if (command != null)
{
context.DeviceCommands.Remove(command);
context.SaveChanges();
}
}
}
示例4: Delete
public void Delete(int id)
{
using (var context = new DeviceHiveContext())
{
var network = context.Networks.Find(id);
if (network != null)
{
context.Networks.Remove(network);
context.SaveChanges();
}
}
}
示例5: Delete
public void Delete(int id)
{
using (var context = new DeviceHiveContext())
{
var deviceClass = context.DeviceClasses.Find(id);
if (deviceClass != null)
{
context.DeviceClasses.Remove(deviceClass);
context.SaveChanges();
}
}
}
示例6: Delete
public void Delete(int id)
{
using (var context = new DeviceHiveContext())
{
var oauthClient = context.OAuthClients.Find(id);
if (oauthClient != null)
{
context.OAuthClients.Remove(oauthClient);
context.SaveChanges();
}
}
}
示例7: Delete
public void Delete(int id)
{
using (var context = new DeviceHiveContext())
{
var equipment = context.Equipments.Find(id);
if (equipment != null)
{
context.Equipments.Remove(equipment);
context.SaveChanges();
}
}
}
示例8: Delete
public void Delete(int id)
{
using (var context = new DeviceHiveContext())
{
var notification = context.DeviceNotifications.Find(id);
if (notification != null)
{
context.DeviceNotifications.Remove(notification);
context.SaveChanges();
}
}
}
示例9: Delete
public void Delete(int id)
{
using (var context = new DeviceHiveContext())
{
var user = context.Users.Find(id);
if (user != null)
{
context.Users.Remove(user);
context.SaveChanges();
}
}
}
示例10: Save
public void Save(DeviceClass deviceClass)
{
if (deviceClass == null)
throw new ArgumentNullException("deviceClass");
using (var context = new DeviceHiveContext())
{
context.DeviceClasses.Add(deviceClass);
if (deviceClass.ID > 0)
{
context.Entry(deviceClass).State = EntityState.Modified;
}
context.SaveChanges();
}
}
示例11: Save
public void Save(Network network)
{
if (network == null)
throw new ArgumentNullException("network");
using (var context = new DeviceHiveContext())
{
context.Networks.Add(network);
if (network.ID > 0)
{
context.Entry(network).State = EntityState.Modified;
}
context.SaveChanges();
}
}
示例12: Save
public void Save(OAuthClient oauthClient)
{
if (oauthClient == null)
throw new ArgumentNullException("oauthClient");
using (var context = new DeviceHiveContext())
{
context.OAuthClients.Add(oauthClient);
if (oauthClient.ID > 0)
{
context.Entry(oauthClient).State = EntityState.Modified;
}
context.SaveChanges();
}
}
示例13: Save
public void Save(User user)
{
if (user == null)
throw new ArgumentNullException("user");
using (var context = new DeviceHiveContext())
{
context.Users.Add(user);
if (user.ID > 0)
{
context.Entry(user).State = EntityState.Modified;
}
context.SaveChanges();
}
}
示例14: Save
public void Save(Equipment equipment)
{
if (equipment == null)
throw new ArgumentNullException("equipment");
using (var context = new DeviceHiveContext())
{
context.DeviceClasses.Attach(equipment.DeviceClass);
context.Equipments.Add(equipment);
if (equipment.ID > 0)
{
context.Entry(equipment).State = EntityState.Modified;
}
context.SaveChanges();
}
}
示例15: Save
public void Save(DeviceNotification notification)
{
if (notification == null)
throw new ArgumentNullException("notification");
using (var context = new DeviceHiveContext())
{
context.Devices.Attach(notification.Device);
context.DeviceNotifications.Add(notification);
if (notification.ID > 0)
{
context.Entry(notification).State = EntityState.Modified;
}
context.SaveChanges();
}
}