How to return array from database in c#

Kuke

I want to return my result as array list. My code looks like this:

public Person Get(string doctorCode)
{
     using (PharmaOCEAN_LTEntities entities = new PharmaOCEAN_LTEntities())                   
     {
         return entities.Person.FirstOrDefault(e => e.DoctorLicenseNumber == doctorCode);
     }
}

Some guy informed me that selected (all) result will be an array, so I tried this way, but im getting an error with select statement:

public IList<Person> Get(string doctorCode)
{
    using (PharmaOCEAN_LTEntities entities = new PharmaOCEAN_LTEntities())                   
    {
        return entities.Person.Select<Person>(e => e.DoctorLicenseNumber == doctorCode);
    }
}

any opinions?

Roelant M

Yeah sure you can! As a array:

public Person[] Get(string doctorCode)
{
    using (PharmaOCEAN_LTEntities entities = new PharmaOCEAN_LTEntities())                   
    {
        return entities.Person.Where(e => e.DoctorLicenseNumber == doctorCode).ToArray();
    }
}

As a list:

public IEnumerable<Person> Get(string doctorCode)
{
    using (PharmaOCEAN_LTEntities entities = new PharmaOCEAN_LTEntities())                   
    {
        return entities.Person.Where(e => e.DoctorLicenseNumber == doctorCode).ToList();
    }
}

not sure if it compiles, but you get the message :)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to "return" an array from a function to main in c

From Dev

C: how to return array of numbers from a function

From Dev

How to find index of array of records return from database in rails?

From Dev

How could I return array and use it in anoher class from database

From Dev

How to return an array in c

From Dev

How to return array in c?

From Dev

Return just an object within array from database

From Java

C++ How to return array of objects from a function

From Dev

How to return an array as table from C function to lua?

From Dev

c# How to return a byte array from pdf using iTextsharp

From Dev

How to return a multidimensional character array from a function in a header file in C

From Dev

How to return a 2D array from a C function?

From Dev

How can I return a character array from a function in C?

From Dev

How to return a multidimensional character array from a function in a header file in C

From Dev

How to return a 3D array from C to Java?

From Dev

How to return dynamic array from void function in c?

From Dev

how to return 2 dim char array from function in C

From Dev

How to return an array from a c# dll to php

From Dev

How to return a pointer struct array from a function in C

From Dev

How to call a C DLL from a VBA application and return an array?

From Dev

How to return a null value from a database

From Dev

How to return last record from database in codeigniter?

From Dev

How to return a single value from a database?

From Dev

How to return one variable from database?

From Dev

How to return a null value from a database

From Dev

How to return records from database using javalite?

From Dev

Laravel - How to store a return from a function to the database?

From Dev

How to add to array from list and return array

From Dev

How to return a new array from an array in java

Related Related

  1. 1

    How to "return" an array from a function to main in c

  2. 2

    C: how to return array of numbers from a function

  3. 3

    How to find index of array of records return from database in rails?

  4. 4

    How could I return array and use it in anoher class from database

  5. 5

    How to return an array in c

  6. 6

    How to return array in c?

  7. 7

    Return just an object within array from database

  8. 8

    C++ How to return array of objects from a function

  9. 9

    How to return an array as table from C function to lua?

  10. 10

    c# How to return a byte array from pdf using iTextsharp

  11. 11

    How to return a multidimensional character array from a function in a header file in C

  12. 12

    How to return a 2D array from a C function?

  13. 13

    How can I return a character array from a function in C?

  14. 14

    How to return a multidimensional character array from a function in a header file in C

  15. 15

    How to return a 3D array from C to Java?

  16. 16

    How to return dynamic array from void function in c?

  17. 17

    how to return 2 dim char array from function in C

  18. 18

    How to return an array from a c# dll to php

  19. 19

    How to return a pointer struct array from a function in C

  20. 20

    How to call a C DLL from a VBA application and return an array?

  21. 21

    How to return a null value from a database

  22. 22

    How to return last record from database in codeigniter?

  23. 23

    How to return a single value from a database?

  24. 24

    How to return one variable from database?

  25. 25

    How to return a null value from a database

  26. 26

    How to return records from database using javalite?

  27. 27

    Laravel - How to store a return from a function to the database?

  28. 28

    How to add to array from list and return array

  29. 29

    How to return a new array from an array in java

HotTag

Archive