我需要实现一个方法,该方法将地址拆分为各个部分并从地址表中返回任何匹配项。如果没有找到匹配项,我希望能够返回一个指示失败位置的值。每个输入参数在表中都有一个对应的字段。
签名看起来像这样:
List<Address> MatchAddress(string zipCode, string streetName, string houseNumber, string houseLetter, string floor, string appartmentNo, out int mismatchPosition)
{
// return matching addresses
// if none found, return the position where it stopped matching
// zipCode is position 0, appartmentNo is position 5
//
// an empty param value indicates "don't check"
}
我知道我可以构造方法,以便从所有参数开始,执行查询,然后逐个参数(从右侧)删除参数,直到找到匹配项或我用完参数,但是我可以构造一个查询那比那更有效,即最小化对数据库的调用次数,甚至可能是一次调用?