public void GetStateConditions(string systemWorkCondition, int countModule, int elementIndex) { BuildStateString(); var moduleCondition = new ModuleCondition(); for (var i = 0; i < countModule; i++) { var index = i + 1; PropertyInfo propertyInfo = moduleCondition.GetType().GetProperty("M" + index); propertyInfo.SetValue(moduleCondition, Convert.ChangeType(StateElements[i].State, propertyInfo.PropertyType), null); } var list = new List <ModuleCondition>(); list.Add(moduleCondition); string whereClause = String.Format("m1 and m2"); var queryResult = list .Where(StringHelper.GetUpScript(systemWorkCondition)).Any(); // see if it's a match if (queryResult) { StateType = StateType.WorkingState; StateTypeString = Properties.Resources.WorkingState; } if (!queryResult) { if (StateElements[elementIndex].State == false && StateElements[elementIndex].AllRepairCount == StateElements[elementIndex].CurrentRepairCount) { StateType = StateType.RefusalState; StateTypeString = Properties.Resources.RefusalState; } else if (StateElements.Any(w => w.AllRepairCount != w.CurrentRepairCount)) { StateType = StateType.DowntimeState; StateTypeString = Properties.Resources.DowntimeState; } } }