<分区>
我有一些方法可以返回过去 360 天、180 天和 90 天未查询的联系人列表。
最近361天没有查询过的人,180天和90天的查询也会返回。
我以为我可以用 Except 来做到这一点,但这肯定行不通,
public class Contacto
{
public int IdContacto { get; set; }
public string PrimerApellido { get; set; }
public string PrimerNombre { get; set; }
public string SegundoApellido { get; set; }
public string SegundoNombre { get; set; }
public object Telefonos { get; set; }
public int TipoTelefono { get; set; }
public int IdEstado { get; set; }
public DateTime? FechaArchivado { get; set; }
public DateTime? FechaConsulta { get; set; }
GetOldContacts 方法
private static List<Contacto> GetOldContacts(int numberOfDays)
{
try
{
DateTime filter = DateTime.Now.AddDays(-numberOfDays);
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(ConfigurationSettings.Apiurl);
HttpResponseMessage response = client.GetAsync("api/ContactosDepurar?FechaInicial="+filter.ToShortDateString()).Result;
if (response.IsSuccessStatusCode)
{
return response.Content.ReadAsAsync<List<Contacto>>().Result;
}
else
{
System.Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
return null;
}
}
catch (Exception ex)
{
System.Console.WriteLine(ex.Message);
return null;
}
}
还有我的 Except 逻辑
IEnumerable<Contacto> contactosDoceMeses = GetOldContacts(ConfigurationSettings.Ciclo3Dias);
IEnumerable<Contacto> contactosSeisMeses = GetOldContacts(ConfigurationSettings.Ciclo2Dias).Except<Contacto>(contactosDoceMeses);
IEnumerable<Contacto> contactosTresMeses = GetOldContacts(ConfigurationSettings.Ciclo1Dias).Except<Contacto>(contactosSeisMeses);
问题是第二个查询返回了第一个的项目,它不应该