Select Distinct from EntityCollection

Posts   
 
    
jovball
User
Posts: 443
Joined: 23-Jan-2005
# Posted on: 06-Sep-2012 05:04:08   

I have an EntityCollection based on a view that has several properties in a partial class. I need to get a distinct set of rows but I also need the values from the properties. Otherwise I could use FetchTypedList with ResultSetFields.

Here's the query I want (the query is really on a view that does not have DISTINCT ).


Select DISTINCT 
c.CustomerId, companyName 
from customers c
join orders o
on c.CustomerId = o.CustomerId
where orderDate >= '1998-04-20'

However, the entity has a partial class with properties.


 public partial class OrderHeaderViewEntity
    {

        public string CityRegionCountry
        {
            get { return string.Format("{0} {1} {2}", City, Region, Country); }
        }
        

    }

The partial class properties do not need to be considered for the DISTINCT, they are just concatenations or calculated fields as shown above.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 06-Sep-2012 07:00:10   

Hi Joel,

Whatever you have as custom properties on the entity, are just memory expressions and thus those are not considered in any kind of query. I don't quite understand what you really want to achieve.

LLBLGen doesn't know how is the query of your View, it only knows the fields it returns. So it doesn't know if a DISTINCT is needed. As you don't have joins in the fetch routine, no DISTINCT is needed apparently. When the entities are materialized however, LLBLGen prevents that duplicates are inserted in the collection. I don't know if that is what you are asking.

David Elizondo | LLBLGen Support Team