本文整理汇总了C#中DeviceHive.Data.EF.DeviceHiveContext类的典型用法代码示例。如果您正苦于以下问题:C# DeviceHiveContext类的具体用法?C# DeviceHiveContext怎么用?C# DeviceHiveContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeviceHiveContext类属于DeviceHive.Data.EF命名空间,在下文中一共展示了DeviceHiveContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAll
public List<OAuthClient> GetAll(OAuthClientFilter filter = null)
{
using (var context = new DeviceHiveContext())
{
return context.OAuthClients.Filter(filter).ToList();
}
}
示例2: Get
public DeviceClass Get(int id)
{
using (var context = new DeviceHiveContext())
{
return context.DeviceClasses.Find(id);
}
}
示例3: 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();
}
}
示例4: GetAll
public List<User> GetAll()
{
using (var context = new DeviceHiveContext())
{
return context.Users.ToList();
}
}
示例5: 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();
}
}
示例6: Get
public OAuthClient Get(int id)
{
using (var context = new DeviceHiveContext())
{
return context.OAuthClients.Find(id);
}
}
示例7: GetAll
public List<Network> GetAll()
{
using (var context = new DeviceHiveContext())
{
return context.Networks.ToList();
}
}
示例8: Get
public Network Get(int id)
{
using (var context = new DeviceHiveContext())
{
return context.Networks.Find(id);
}
}
示例9: GetAll
public List<User> GetAll(UserFilter filter = null)
{
using (var context = new DeviceHiveContext())
{
return context.Users.Filter(filter).ToList();
}
}
示例10: GetAll
public List<DeviceClass> GetAll()
{
using (var context = new DeviceHiveContext())
{
return context.DeviceClasses.ToList();
}
}
示例11: Get
public User Get(int id)
{
using (var context = new DeviceHiveContext())
{
return context.Users.Find(id);
}
}
示例12: GetByDeviceAndCode
public DeviceEquipment GetByDeviceAndCode(int deviceId, string code)
{
using (var context = new DeviceHiveContext())
{
return context.DeviceEquipments.FirstOrDefault(e => e.Device.ID == deviceId && e.Code == code);
}
}
示例13: GetByDevice
public List<DeviceEquipment> GetByDevice(int deviceId)
{
using (var context = new DeviceHiveContext())
{
return context.DeviceEquipments.Where(e => e.Device.ID == deviceId).ToList();
}
}
示例14: Get
public DeviceNotification Get(int id)
{
using (var context = new DeviceHiveContext())
{
return context.DeviceNotifications.Find(id);
}
}
示例15: Get
public DeviceEquipment Get(int id)
{
using (var context = new DeviceHiveContext())
{
return context.DeviceEquipments.Find(id);
}
}