我正在尝试将issetting标志设置为true,如果存在child父]。
//Class file public class EopsModule { public int ID { get; set; } public string ModuleCode { get; set; } public string Description { get; set; } public bool IsDefaultModule { get; set; } public int? ParentID { get; set; } public bool IsSetting { get; set; } public List<EopsModule> Children { get; set; } } public IResponseResult GetApplicationSettingWithModule() { IResponseResult responseResult = new ResponseResult(); dynamic dynamic = new ExpandoObject(); try { var settingsDetails = _databaseManager.GetMultipleDataByJson(DatabaseStoredProcedures.spGetAllApplicationSetting.ToString()).Result; var oObjectDeserializeObject = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(settingsDetails); //get here all EopsModule in List<EopsModule> var moduleTreeHierarchy = _eopsModuleManager.GetAllEopsModuleWithHierarchy().Result; dynamic.settingsDetails = oObjectDeserializeObject; dynamic.moduleTreeHierarchy = moduleTreeHierarchy; string oModuleCode = string.Empty; foreach (var item in oObjectDeserializeObject) { oModuleCode = item.moduleCode; moduleTreeHierarchy. Where(x => x.ModuleCode == oModuleCode).ToList().ForEach(x => { x.IsSetting = true; }); } responseResult = Helper.Response.ResponseModel(dynamic, true, Helper.Constants.ApiSuccess, HttpStatusCode.OK, true); } catch (Exception) { responseResult = Helper.Response.ResponseModel(null, false, Helper.Constants.ApiFailure, HttpStatusCode.BadRequest, true); } return responseResult; }
我正在迭代的循环适用于父级,但是,它不会更新子级值,想知道是否可以通过递归函数来实现。
请使用现有代码查找输出:
我正在尝试将issetting标志设置为true,如果父母存在孩子。 //类文件公共类EopsModule {public int ID {get;组; }公共字符串ModuleCode {get;组; ...
您是否尝试过这种方法?我没有通过编译器传递它,但是您会明白的。