Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

grouping - Linq extract a count() value from a data object -


i have divassignments has potential multiple rows rni, official id, according compound key of indictment , booking numbers.

rni    booking  indictment 12345  954445   10 12345 12345  954445   10 12346 12345  954445   10 12347 

so id has count of 3 single booking number rni.

i lost attempting generate count , group booking number:

var morethen = da in divassignments     select new { da.rni, indictmentcount = da.indictmentnumber.count() }; 

most of examples dealing static int[] , don't seem work in case.

how group , count? if put in having fantastic.

from t-sql pov i'd use this:

select rni, bookingnumber, count(*) indictmentcount  divassignments group rni, bookingnumber   having count(*) > 0  

tia

how this:

var query = item in divassignments group item item.rni grouping select new {   id = grouping.key,   count = grouping.count() } 

if you're interested in grouping both rni , booking number, change this:

var query = item in divassignements    group item new { item.rni, a.booking } grouping    select new     {       id = grouping.key,       count = grouping.count     }; 

or

var query = item in divassignments     group item item grouping     select new     {       id = grouping.key,       count = grouping.count()     } 

and implement iequatable on divassignment object support equality comparison. other option if you'd write iequalitycomparer instance composite key comparison. query like:

var query =    divassignments       .groupby(i => i, new mycustomequalitycomparer())       .select(i => new { key = i.key, count = i.count()); 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -