none
Linq Query -Datatable Max. Value RRS feed

  • Question

  • Hi,

    I have a datatable invoice. Now Iam looking to find the particular item_code, last date entry of unit_price...

    var Query =(from t1 in invoice.AsEnumerable() where t1["itm_code"]== MySelImCode & t1["grn_date"]=????Max(???????grn_date)).Select(t1["unit_price"]);

    Thanks


    --------------------------------------------------------------------------------
    U.PARANTHAMAN

    • Changed type Paramu Thursday, September 29, 2011 8:57 PM question
    • Edited by Paramu Thursday, September 29, 2011 8:59 PM font not clear
    Thursday, September 29, 2011 8:55 PM

Answers

All replies

  • Hi,

    Please, try with something like this:

    var query = from t1 in invoice
            group t1 by t1.item_code into g 
            where t1.item_code == MySelImCode
            select new { Unit_Price = g.unit_price , Date = g.Max(t=>t.Date)}; 
    
    

    Regards,

    JA Reyes.


    Please remember to Vote & "Mark As Answer" if this post is helpful to you.
    Por favor, recuerda Votar y "Marcar como respuesta" si la solución de esta pregunta te ha sido útil.
    Friday, September 30, 2011 7:30 AM
  • Hi Reyes,

    Actuallay its a datatable, I asked in wrong place I think. Thanks for the helps.


    U.PARANTHAMAN

    • Edited by Paramu Friday, September 30, 2011 4:25 PM
    Friday, September 30, 2011 4:24 PM
  • Well,

    Anyway try lo see if this other thread can help you:

    http://social.msdn.microsoft.com/Forums/eu/adodotnetdataproviders/thread/3dc001ae-031c-4ef1-a911-291953af4b9a

    Best regards,

    JA Reyes.


    Please remember to Vote & "Mark As Answer" if this post is helpful to you.
    Por favor, recuerda Votar y "Marcar como respuesta" si la solución de esta pregunta te ha sido útil.
    • Marked as answer by Paramu Saturday, October 1, 2011 11:06 AM
    Saturday, October 1, 2011 8:56 AM
  • Thanks Reyees
    U.PARANTHAMAN
    Saturday, October 1, 2011 11:07 AM