cotopboy
12/9/2013 - 8:40 AM

Expression 用法。

Expression 用法。

Expression<Func<string, string, bool>> strCmp = (r, t) => (r == null) || ((t == null) && (r == "")) || (r == t);
Expression<Func<int?, int?, bool>> intCmp = (r, t) => (r == null) || (r == t);

                filter = filter.AsExpandable().Where(m =>
                    (intCmp.Invoke(row.module_id, m.module_id)) &&
                    (strCmp.Invoke(row.module_manufacturer_serialnumber, m.manufacturer_sn)) &&
                    (strCmp.Invoke(row.module_customer_identifier, m.customer_identifier)) &&
                    (strCmp.Invoke(row.module_customer_name, m.customer_name)) &&
                    (strCmp.Invoke(row.module_firmware_version, m.firmware_version)) &&
                    (strCmp.Invoke(row.module_ip_type, m.ip_type)) &&
                    (strCmp.Invoke(row.module_mac_address, m.mac_address)) &&
                    (strCmp.Invoke(row.module_mac_auto_detection, m.manufacturer_mac_dyn_active)) &&
                    (strCmp.Invoke(row.dhcp_server_ip_address, m.dhcp_ip_address)) &&
                    (strCmp.Invoke(row.module_install_status, m.install_status)) &&
                    (strCmp.Invoke(row.module_status, m.status)) &&
                    (intCmp.Invoke(row.module_point_id, (int?)m.module_point_id)) &&
                    (strCmp.Invoke(row.module_model_type, m.model_type)) &&
                    (strCmp.Invoke(row.module_remark_type, m.remark_type))
                    );