sql to C# functional query -


working in linqpad, trying convert sql query c# functional statement. sql:

select count(distinct([case_no])) [tbl]  

i have tried variations of things like:

var cnt = tbl.case_no.distinct().count();   var cnt = tbl.count(n => n.case_no.distinct());   

"select count of distinct case_no values in tbl table".
think distinct qualifier causing me trouble.

update: runs, error:
var q2 = fl_modifies.selectmany(n => n.case_pol_no.distinct());
q2.dump();
"sequence operators not supported type 'system.string'."

you need "extract" case_no values form result set, then distinct count:

var cnt = tbl.select(t => t.case_no).distinct().count() 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -