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:

enter image description here

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

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

how to receive file in java(servlet/jsp) -