Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. fetch distinct record from the custom data type in ado.net entity framework

fetch distinct record from the custom data type in ado.net entity framework

Scheduled Pinned Locked Moved C#
csharpsales
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pankaj Saha
    wrote on last edited by
    #1

    Hi, I have created a class customer and where I am fetching all the records from the customer table through the procedure. Now I want to fetch all the distinct city from the customer table. Here is the code p

    ublic List<City> GetAllDistinctCity()
    {
    //passing the connection string to the mode
    EntityDataMode entity = new EntityDataMode (Connection.ConnectionString);
    try
    {

                //List<Customer> = entity.GetAllCustomer().List();
    
                //fetching all the customers 
                var collection = entity.GetAllCustomer();
    
                //fetch all the distinct city from the customer
    
            }
            catch (Exception ex)
            {
                //
            }
    
            
        }
    

    If I create the view for the city, then I can directory fetch all the distinct city through the procedure, but I do not want to create any separate view for only city, which is a field of a customer table, because later I need to fetch another distinct field, then I have to again create a view for that field. Is there any simple method by which I can fetch distinct city using the GetAllCustomer() procedure

    Pankaj

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups