lunes, 22 de noviembre de 2010

Join entre DataTables en LINQ

private void algo()
{
     DataTable dtPolizas = new DataTable();
     DataTable dtServicios = new DataTable();
     var ret = from p in dtPolizas.AsEnumerable()
               join q in dtServicios.AsEnumerable() on p.Field<int>("ID") equals q.Field<int>("ID") into UP
               from q in UP.DefaultIfEmpty()
               where (q.Field<string>("estado") == "00" || q.Field<string>("estado") == "12" && q.Field<int>("estado") == Convert.ToInt32(DateTime.Now.AddDays(-90).ToString("yyyyMMdd")))
               select new
               {
                   ID = Convert.ToDateTime(p.Field<int>("ID")),
                   Type = p.Field<string>("Type"),
                   Part = q.Field<int>("Part"),
                   Quantity = q.Field<int>("Quantity")
               };
     foreach (var ins in ret)
     {
     }
}

No hay comentarios:

Publicar un comentario

 
Locations of visitors to this page