fetch distinct record from the custom data type in ado.net entity framework
-
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