本文整理汇总了C#中DeviceHive.Data.EF.DeviceHiveContext.Entry方法的典型用法代码示例。如果您正苦于以下问题:C# DeviceHiveContext.Entry方法的具体用法?C# DeviceHiveContext.Entry怎么用?C# DeviceHiveContext.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceHive.Data.EF.DeviceHiveContext
的用法示例。
在下文中一共展示了DeviceHiveContext.Entry方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
}
示例4: 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();
}
}
示例5: 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();
}
}
示例6: 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();
}
}
示例7: 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();
}
}
示例8: 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();
}
}
示例9: Save
public void Save(DeviceCommand command)
{
if (command == null)
throw new ArgumentNullException("command");
using (var context = new DeviceHiveContext())
{
context.Devices.Attach(command.Device);
context.DeviceCommands.Add(command);
if (command.ID > 0)
{
context.Entry(command).State = EntityState.Modified;
}
context.SaveChanges();
}
}
示例10: Save
public void Save(UserNetwork userNetwork)
{
if (userNetwork == null)
throw new ArgumentNullException("userNetwork");
using (var context = new DeviceHiveContext())
{
context.Users.Attach(userNetwork.User);
context.Networks.Attach(userNetwork.Network);
context.UserNetworks.Add(userNetwork);
if (userNetwork.ID > 0)
{
context.Entry(userNetwork).State = EntityState.Modified;
}
context.SaveChanges();
}
}
示例11: Save
public void Save(Device device)
{
if (device == null)
throw new ArgumentNullException("device");
if (device.GUID == Guid.Empty)
throw new ArgumentException("Device.ID must have a valid value!", "device.ID");
using (var context = new DeviceHiveContext())
{
if (device.Network != null)
{
context.Networks.Attach(device.Network);
}
context.DeviceClasses.Attach(device.DeviceClass);
context.Devices.Add(device);
if (device.ID > 0)
{
context.Entry(device).State = EntityState.Modified;
}
context.SaveChanges();
}
}