Possible Duplicate:
How can I pass an anonymous type to a method?
I have a terrible problem here, hope you can help me solve it
have the following linq-to-sql query, very simple:
var i = from cr in db.ComprobanteRecepcions join c in db.Comprobantes
on new { cr.RFC, cr.RFCProveedor, cr.Folio, cr.Serie } equals new { c.RFC, c.RFCProveedor, c.Folio, c.Serie }
where
Convert.ToString(cr.IDSucursal) == "4" &&
cr.RFC == "FIN020938SVR "
select new { cr.Serie, cr.Folio, cr.IDStatusComp, c.FechaEmision, c.Comentarios, c.Total };
I want to pass i to a method, something like this
mymethod void(var a)
Of course this can't be done... and creating a Type (class) to return it, something like this
select new MyType {cr.Serie, cr.Folio, cr.IDStatusComp, c.FechaEmision, c.Comentarios, c.Total };
is impractical, such as returning a XElement or XDocument so what else can I do ?? I have to fill a datagrid with the var i variable and I don't know how to get this variable, I also googled for answers but there's not and easy one...
Understand that I'm a newbie using c#, .net and MS Technologies (I was a Java programmer)
What about returning something like this
public class MyType
{
public ComprobanteRecepcions Recepcions { get;set; }
public Comprobantes Comprobantes { get;set; }
}
and in your linq:
select new MyType { Recepcions = cr, Comprobantes = c }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With