예제 #1
0
        public void TestMethodGetData()
        {
            using (var ctx = new PortnoxContext())
            {
                var sw = ctx.Switches
                         .Include(x => x.Ports)
                         .Include(x => x.Events)
                         .FirstOrDefault(x => x.Id == "1.1.1.1");

                var p = ctx.Ports
                        .Include(x => x.Events)
                        .Include(x => x.Devices)
                        .Single(x => x.Id == "1.1.1.1:12");

                var dIds = ctx.Events
                           .Where(x => x.PortId == p.Id && x.DeviceId != null)
                           .Select(x => x.DeviceId)
                           .Distinct().ToArray();

                var f = ctx.Devices.First();
                var d = ctx.Devices.Where(x => dIds.Contains(x.Id)).ToArray();

                p.Devices = ctx.Devices
                            .Where(x => dIds.Contains(x.Id)).ToArray();
            }
        }
 public async Task <Event> GetEventAsync(int id)
 {
     using (var ctx = new PortnoxContext())
     {
         return(await ctx.Events
                .SingleAsync(x => x.Id == id));
     }
 }
 public async Task <Switch> GetSwitchAsync(string id)
 {
     using (var ctx = new PortnoxContext())
     {
         return(await ctx.Switches
                .Include(x => x.Ports)
                .Include(x => x.Events)
                .SingleAsync(x => x.Id == id));
     }
 }
 public async Task <Port> GetPortAsync(string id)
 {
     using (var ctx = new PortnoxContext())
     {
         return(await ctx.Ports
                .Include(x => x.Events)
                .Include(x => x.Devices)
                .SingleAsync(x => x.Id == id));
     }
 }