c# - Linq to SQL Distinct Value Dictionary -


i wish use linq sql query turn dictionary of distinct values. both key , value come query..

var model = db.landgrid_plss_sections                 .select(x => new {x.meridian_code,x.meridian})                 .todictionary(kvp=> kvp.meridian_code string, kvp=> kvp.meridian string)                 .distinct(); 

this returns exception saying item key value exists.

this dictionary need of type dictionary<string,string>

update

in table, meridian_code have same meridian value. occur multiple times in table. meridian user friendly version of code. need both available me in view.

try this:

var model = db.landgrid_plss_sections     .groupby(s => s.meridian_code, s => s.meridian)     .todictionary(s => s.key, v => v.first()); 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -