public GateInfo[] GetBridgeFromRegion(string id) { List <GateInfo> list = new List <GateInfo>(); var gateIds = Bridges?.Where(_ => _.Links.Any(l => l == id)).Select(_ => _.ID); if (Gates != null && gateIds.Count() > 0) { foreach (var gate in gateIds) { var reg = Gates.FirstOrDefault(_ => _.ID == gate); if (reg != null) { list.Add(reg); } } } return(list.ToArray()); }
public void RemoveBridge(string id, string regId) { Bridges?.Where(b => b.ID == id).ToList().ForEach(_ => _.Links?.RemoveAll(r => r == regId)); Bridges?.RemoveAll(_ => _.Links == null || _.Links.Count == 0);//删除空的关联列表 }