当前位置: 首页>>代码示例>>C#>>正文


C# EF.DeviceHiveContext类代码示例

本文整理汇总了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();
     }
 }
开发者ID:bestpetrovich,项目名称:devicehive-.net,代码行数:7,代码来源:OAuthClientRepository.cs

示例2: Get

 public DeviceClass Get(int id)
 {
     using (var context = new DeviceHiveContext())
     {
         return context.DeviceClasses.Find(id);
     }
 }
开发者ID:reven86,项目名称:framework,代码行数:7,代码来源:DeviceClassRepository.cs

示例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();
            }
        }
开发者ID:EugeneTikhonov,项目名称:devicehive-.net,代码行数:26,代码来源:DeviceClassRepository.cs

示例4: GetAll

 public List<User> GetAll()
 {
     using (var context = new DeviceHiveContext())
     {
         return context.Users.ToList();
     }
 }
开发者ID:oryol,项目名称:devicehive-.net,代码行数:7,代码来源:UserRepository.cs

示例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();
            }
        }
开发者ID:bestpetrovich,项目名称:devicehive-.net,代码行数:26,代码来源:AccessKeyRepository.cs

示例6: Get

 public OAuthClient Get(int id)
 {
     using (var context = new DeviceHiveContext())
     {
         return context.OAuthClients.Find(id);
     }
 }
开发者ID:bestpetrovich,项目名称:devicehive-.net,代码行数:7,代码来源:OAuthClientRepository.cs

示例7: GetAll

 public List<Network> GetAll()
 {
     using (var context = new DeviceHiveContext())
     {
         return context.Networks.ToList();
     }
 }
开发者ID:oryol,项目名称:devicehive-.net,代码行数:7,代码来源:NetworkRepository.cs

示例8: Get

 public Network Get(int id)
 {
     using (var context = new DeviceHiveContext())
     {
         return context.Networks.Find(id);
     }
 }
开发者ID:oryol,项目名称:devicehive-.net,代码行数:7,代码来源:NetworkRepository.cs

示例9: GetAll

 public List<User> GetAll(UserFilter filter = null)
 {
     using (var context = new DeviceHiveContext())
     {
         return context.Users.Filter(filter).ToList();
     }
 }
开发者ID:bestpetrovich,项目名称:devicehive-.net,代码行数:7,代码来源:UserRepository.cs

示例10: GetAll

 public List<DeviceClass> GetAll()
 {
     using (var context = new DeviceHiveContext())
     {
         return context.DeviceClasses.ToList();
     }
 }
开发者ID:reven86,项目名称:framework,代码行数:7,代码来源:DeviceClassRepository.cs

示例11: Get

 public User Get(int id)
 {
     using (var context = new DeviceHiveContext())
     {
         return context.Users.Find(id);
     }
 }
开发者ID:oryol,项目名称:devicehive-.net,代码行数:7,代码来源:UserRepository.cs

示例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);
     }
 }
开发者ID:reven86,项目名称:framework,代码行数:7,代码来源:DeviceEquipmentRepository.cs

示例13: GetByDevice

 public List<DeviceEquipment> GetByDevice(int deviceId)
 {
     using (var context = new DeviceHiveContext())
     {
         return context.DeviceEquipments.Where(e => e.Device.ID == deviceId).ToList();
     }
 }
开发者ID:reven86,项目名称:framework,代码行数:7,代码来源:DeviceEquipmentRepository.cs

示例14: Get

 public DeviceNotification Get(int id)
 {
     using (var context = new DeviceHiveContext())
     {
         return context.DeviceNotifications.Find(id);
     }
 }
开发者ID:reven86,项目名称:framework,代码行数:7,代码来源:DeviceNotificationRepository.cs

示例15: Get

 public DeviceEquipment Get(int id)
 {
     using (var context = new DeviceHiveContext())
     {
         return context.DeviceEquipments.Find(id);
     }
 }
开发者ID:reven86,项目名称:framework,代码行数:7,代码来源:DeviceEquipmentRepository.cs


注:本文中的DeviceHive.Data.EF.DeviceHiveContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。