private DeviceQueryRow ProcessMultiResults(DynamicSql query, object[] objs) { var row = new DeviceQueryRow(); for (var i = 0; i < query.MultiResults.Count; i++) { var r = query.MultiResults[i]; switch (r.Key) { case DeviceQueryProjection.INFO: row.Device = objs[i] as Device; break; case DeviceQueryProjection.ACCOUNT: row.DeviceAccount = objs[i] as AppUserRelationship; break; case DeviceQueryProjection.AREA: row.Area = objs[i] as AreaRelationship; break; case DeviceQueryProjection.BUILDING: row.Building = objs[i] as BuildingRelationship; break; case DeviceQueryProjection.FLOOR: row.Floor = objs[i] as FloorRelationship; break; case DeviceQueryProjection.LOCATION: row.Location = objs[i] as LocationRelationship; break; case DeviceQueryProjection.SCHEDULE: row.Schedule = objs[i] as ScheduleRelationship; break; } } return(row); }
public IDictionary <string, object> GetDeviceDynamic( DeviceQueryRow row, DeviceQueryProjection projection, DeviceQueryOptions options) { var obj = new Dictionary <string, object>(); foreach (var f in projection.GetFieldsArr()) { switch (f) { case DeviceQueryProjection.INFO: { var entity = row.Device; obj["id"] = entity.Id; obj["code"] = entity.Code; obj["name"] = entity.Name; obj["description"] = entity.Description; obj["area_id"] = entity.AreaId; obj["buliding_id"] = entity.BuildingId; obj["floor_id"] = entity.FloorId; obj["location_id"] = entity.LocationId; obj["lat"] = entity.Lat; obj["lon"] = entity.Lon; obj["schedule_id"] = entity.ScheduleId; } break; case DeviceQueryProjection.AREA: { var entity = row.Area; if (entity != null) { obj["area"] = new { id = entity.Id, name = entity.Name, code = entity.Code, } } ; } break; case DeviceQueryProjection.FLOOR: { var entity = row.Floor; if (entity != null) { obj["floor"] = new { id = entity.Id, name = entity.Name, code = entity.Code, floor_plan_svg = entity.FloorPlanSvg } } ; } break; case DeviceQueryProjection.BUILDING: { var entity = row.Building; if (entity != null) { obj["building"] = new { id = entity.Id, name = entity.Name, code = entity.Code } } ; } break; case DeviceQueryProjection.LOCATION: { var entity = row.Location; if (entity != null) { obj["location"] = new { id = entity.Id, name = entity.Name, code = entity.Code, } } ; } break; case DeviceQueryProjection.ACCOUNT: { var entity = row.DeviceAccount; obj["account"] = new { id = entity.Id, username = entity.UserName }; } break; case DeviceQueryProjection.SCHEDULE: { var entity = row.Schedule; if (entity != null) { obj["schedule"] = new { id = entity.Id, name = entity.Name, code = entity.Code, } } ; } break; } } return(obj); }