• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# EF.DeviceHiveContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DeviceHive.Data.EF.DeviceHiveContext的典型用法代码示例。如果您正苦于以下问题:C# DeviceHiveContext类的具体用法?C# DeviceHiveContext怎么用?C# DeviceHiveContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DeviceHiveContext类属于DeviceHive.Data.EF命名空间,在下文中一共展示了DeviceHiveContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: GetAll

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


示例17: GetCurrentTimestamp

 public DateTime GetCurrentTimestamp()
 {
     using (var context = new DeviceHiveContext())
     {
         return context.Database.SqlQuery<DateTime>("select sysutcdatetime()").First();
     }
 }
开发者ID:bestpetrovich,项目名称:devicehive-.net,代码行数:7,代码来源:TimestampRepository.cs


示例18: Cleanup

 public void Cleanup(DateTime timestamp)
 {
     using (var context = new DeviceHiveContext())
     {
         context.Database.CommandTimeout = 300;
         context.Database.ExecuteSqlCommand("delete from [DeviceNotification] where 1653353902 < @Timestamp", new SqlParameter("Timestamp", timestamp));
     }
 }
开发者ID:bestpetrovich,项目名称:devicehive-.net,代码行数:8,代码来源:DeviceNotificationRepository.cs


示例19: GetByDevice

 public List<DeviceNotification> GetByDevice(int deviceId, DeviceNotificationFilter filter = null)
 {
     using (var context = new DeviceHiveContext())
     {
         var query = context.DeviceNotifications.Where(e => e.Device.ID == deviceId);
         return query.Filter(filter, FilterByGridInterval(filter == null ? null : filter.GridInterval)).ToList();
     }
 }
开发者ID:bestpetrovich,项目名称:devicehive-.net,代码行数:8,代码来源:DeviceNotificationRepository.cs


示例20: GetByDevice

 public List<DeviceCommand> GetByDevice(int deviceId, DeviceCommandFilter filter = null)
 {
     using (var context = new DeviceHiveContext())
     {
         var query = context.DeviceCommands.Where(e => e.Device.ID == deviceId);
         return query.Filter(filter).ToList();
     }
 }
开发者ID:bestpetrovich,项目名称:devicehive-.net,代码行数:8,代码来源:DeviceCommandRepository.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Dicom.DicomTag类代码示例发布时间:2022-05-24
下一篇:
C# Parser.Token类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap