public static string GenrateMenu(int promoid, string search) { using (OneFineRateEntities _context = new OneFineRateEntities()) { var result = _context.uspGetPropertiesAndChainByPromoCode(promoid, "%" + search + "%"); // var lstResult = result.Where(x => x.Mapped == 1).ToList(); var lstResult = result.ToList(); string ReturnString = ""; foreach (var item in lstResult) { ReturnString += "{ \"id\" : " + item.iPropId + ", \"name\": \"" + item.PropName.Trim() + "\", \"parent\": \"" + item.chainName.Trim() + "\", \"checked\": \"" + item.Mapped + "\"},"; } try { ReturnString = "[" + ReturnString.Substring(0, ReturnString.Length - 1) + "]"; } catch (Exception) { ReturnString = "[]"; } return(ReturnString); } }