locked
in entiry model row count RRS feed

  • Question

  • hi all

    i have a entity data model and write  some code to receive data but how can l handle my codes to

    return a row count like this in tsql select count(*) from .....

     

    my code are like this how can i fount rows count in contacts or return a row count in entity?

     

                FAEM = new FindAllEntitiesMain();
                var Contacts = from a in FAEM.View_Main
                               where a.Contact_Type == 3
                               select a;

     

     


    Thanks Motevallizadeh
    Wednesday, November 10, 2010 8:20 PM

Answers

  • Hi Motevallizadeh,

    Have you tried to use the Count() method ? 

                FAEM = new FindAllEntitiesMain();
                var Contacts = from a in FAEM.View_Main
                               where a.Contact_Type == 3
                               select a;

                int iCount = Contacts.Count();

    Best regards,
    Alex Liang


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, November 15, 2010 6:38 AM

All replies

  • Hi,

    Here you have some samples of how to perform Count operations:

    http://msdn.microsoft.com/en-us/vcsharp/aa336747.aspx

    Best regards,

    JAReyes.


    Please remember to Vote & "Mark As Answer" if this post is helpful to you.
    Por favor, recuerda Votar y "Marcar como respuesta" si la solucion de esta pregunta te ha sido útil.
    • Proposed as answer by Alex Liang Thursday, November 11, 2010 8:49 AM
    • Unproposed as answer by motevallizadeh Thursday, November 11, 2010 10:46 AM
    Wednesday, November 10, 2010 9:15 PM
  • Hi Motevallizadeh,

    Have you tried to use the Count() method ? 

                FAEM = new FindAllEntitiesMain();
                var Contacts = from a in FAEM.View_Main
                               where a.Contact_Type == 3
                               select a;

                int iCount = Contacts.Count();

    Best regards,
    Alex Liang


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, November 15, 2010 6:38 AM