c# - Search List for Records with matching value for a Class Property? -


I have created a Model class in my ASP.NET forms which have been called by Years_Of_Service :

  using the system; Using System.Collections.Generic; Using System.Linq; Using System.Web; Namespace project.models.default {public class years_off services {public in the year}; Set; } Public String Fiscal Year {Received {Return Year + "-" (+ 1 Year); }} Public Decimal Services {get; Set; } Public Decimal Salary {Received; Set; } Public String CoveredEmployer {get; Set; } Public String TotalService {get; Set; } Public String PurchasedorReinstatedService {get; Set; }}}   

I am successfully inquiring with my database through my custom control and refunding the fair value within this model class, although in some select cases, Returned those who have the same [year] value:

grid

What I need to do now is through every unit in my list, and if I have 2 or more institutions near the [year] A is a matching value, please add them together and turned into [dependent employer] the value of "multiple employer".

A simple foreign language loop will take me through each unit, but I'm on a loss how I will do a sub-discovery of each other unit for a matching [year] value and combine 2. Can someone tell me in the right direction how can this be done best?

This is the code of my custom control page that I have done so far:

  Public Partial Class Years Service: System. Web. UI. User control [public list & lt; Years_Of_Service & gt; Laos {Received; Set; } Public Virus_of_Signer y_o_s {get; Set; } Secure Zero Page_load (object sender, event events e) {if (! Page. ISPostback) {ApplyData (); }} Private Voial Upatata () {foreach (Voato in year_of_servir year of year) {// search [value] for [record] with the same (eg "2009-2010") // If found, [Service ] Add End; [Salary] Change the new "merged" record to say "multiple employers" for value [year] under Record [[CoveredEmployer]] salaryGridView.DataSource = lyos; salaryGridView.DataBind (); If (in addition to y_o_s service. Toaster ()! = Null) {creditSalLabel.Text = y_o_s Overall service. Toasting (); } And {creditSalLabel.Text = String.Empty; } If (y_o_s.) Restored service purchased. Toaster ()! = Null) {purchaseCreditLabel.Text = y_o_s. Purchased and restored service Toasting (); } And {purchaseCreditLabel.Text = string.light; }}}}    

You need to use it.

Something must be:

  var grouped beer lys = Laos. Group by (x = & gt; x.Year). Select (x = & new; years_Of_Service () {CoveredEmployer = x.Count ()> 1 "Multiple Employers": x.First (). CoveredAmployer, Year = x.Key, Pay = x.Sum (y = & Gt; y.Salary) // and etc}. List ();    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -