private bool ValidateRolePayComponentFile(DataTable dtRolePayComponent, ref string validationMsg) { var validationResult = true; AdminBusinessLogic bl = new AdminBusinessLogic(sDataSource); DataTable dtEmployeeRole = bl.GetEmployeeRolesList(); var result = dtEmployeeRole.Rows.Cast <DataRow>() .Select(row => row["ID"].ToString()) .ToArray(); string filterQuery = string.Format("RoleId NOT IN ({0})", string.Join(",", result)); DataRow[] drInvalidEmployeeRole = dtRolePayComponent.Select(filterQuery); if (drInvalidEmployeeRole.Length > 0) { foreach (DataRow dr in drInvalidEmployeeRole) { validationMsg += string.Format("{0} Employee Role not matches with existing records for {1}.", Environment.NewLine, dr["Role_Name"].ToString()); } validationResult = false; } var results = (from dr in dtRolePayComponent.AsEnumerable() where dr.Field <double>("TotalAmount").Equals("0") select dr); if (results.Count() > 0) { foreach (DataRow dr in results) { validationMsg += string.Format("{0} TotalAmount should not be zero. Role Name '{1}'", Environment.NewLine, dr["RoleName"]); } validationResult = false; } return(validationResult); }