ado.net - How do I get unique Linq-to-Entities results when there is no primary key? -
i have entity model of oracle data source on have no control. using model query particular view see volume price breaks given product:
as can see, view has no primary key. here linq using:
var db = getoracledatacontext(); var result = db.itempricebreaks_v.where(p => p.stockno == stockid).tolist();
this works degree, instead of returning 4 distinct records own quantities , pricing, returns 4 identical records, each pricing , quantities of first record ($4800, 0, 2).
i have no control on view. there way can structure linq query can 4 distinct values?
select fields care , use distinct(). example:
var result = db.itempricebreaks_v .where(p => p.stockno == stockid) .select(p => p.price) .distinct() .tolist();
however, i'd recommend, along other commenters, primary key involved.
Comments
Post a Comment