Author: Rajeshwaran SP

  • C#: LINQ Join and order by

    Recently, I had a requirement which read as this:

    Allocate payments into the details by contribution type such that oldest due amounts are first allocated based on the allocation order specified.

    To re-phrase it in programming terms, we had a collection that contained due amounts with contribution type and date due. We also had a rule set that defined which contribution type has to be allocated first. Overriding this rule set was the oldest due amount rule.

    So the collection with the due amount and date is defined as below:

    public class Detail
    {
    	public string contribType { get; set; }
    	public decimal amount { get; set; }
    	public DateTime reportingDate { get; set; }
    
    	public Detail(string contribType, decimal amount, DateTime reportingDate)
    	{
    		this.contribType = contribType;
    		this.amount = amount;
    		this.reportingDate = reportingDate;
    	}
    }

    The rule for allocation is defined as:

    public class CodeValue
    {
    	public string codeValue { get; set; }
    	public string allocateOrder { get; set; }
    
    	public CodeValue(string codeValue, string allocateOrder)
    	{
    		this.codeValue = codeValue;
    		this.allocateOrder = allocateOrder;
    	}
    }

    We have multiples ways to implement the logic. Here is an example using LINQ.

     var sortedResult= from detail in detailCollection
                                   join codeValue in codeValueCollection on detail.contribType equals codeValue.codeValue
                                   into joinedDetails
                                   from fullDetail in joinedDetails.DefaultIfEmpty()
                                   orderby detail.reportingDate, fullDetail.allocateOrder
                                   select detail;

    By looping through the resulting ‘sortedResult’ collection, one can easily satisfy the requirement. Elegant code with LINQ.

  • Diwali

    I missed being at home most this Diwali. Usually, since school time, the biggest festival was Diwali. As kids, during lunch time, we used to discuss what crackers we got, 2 shot, 7 shot, fake atom bombs, fancy and novelties like parachute etc. It would start 2 or three weeks before the actual day. My parents used to take me and my sister for Diwali shopping(new clothes) during the Quarterly exam holidays. Well in advance before the crowd.

    Diwali had always been fun time for old and the kids alike. With Diwali, comes bonuses. My mother used to prepare all the snacks at home. I was always excused and allowed to have them even before we prayed; reason: I was just a kid. I used to be the first one to blast off the 50-100-200 walas in the street. It gives me  a sense of fulfillment of  celebrating Diwali. When I grew to be in the teens, we used to go to new releases on Diwali day. Then distribute sweets to friends.

    This year I missed all the fun. I roamed the streets to get to some shop that sell the firecrackers, but I could not find one. Maybe next year!

  • Halloween @ Kings Dominion

    Happy Halloween!

    This weekend was Halloween. I visited Kings Dominion (an amusement park closer to Richmond, VA). Being the first halloween that I was witnessing it was fun.

    First we had the thriller rides till it was about 8 PM, and then the halloween haunt started with the tagline “All your FEAR is here… “. Nice and funny scare zone, themed around harvest, burial grounds, dark groves and people trying to scare you with their costumes. The thing that was more scary was the other people in front getting frightened and falling down. Fun!

    I got scared when someone sitting in the bench, suddenly pushed a ‘Coke Bottle’ styled waste bin towards me…

    I really liked the vampires, they were beautiful just like those from Dracula movies, though they were not scary!

    On the whole, a funny, scary weekend!

  • Fall 2010 in Virginia

    It has been a year since I came here to USA, Yipee!

    Visited the Shenandoah National Park on Sunday. A wonderful drive on the Skyline drive, beautiful fall colors and the Luray caverns. After days of work in the city, it was a nice getaway.

    Rejuvenated! Next is halloween in Kings Dominion…

  • Playstation 3

    After a lot of debates on which gaming station to choose between XBOX, PS3 and Wii, I finally bought a PS3 recently.

    NFS Pro Street, Madden, Uncharted, Prince of Persia, Call of Duty… Purchased these to play around for another one month. Also, I have switched to watching movies on Netflix and DVD’s on my TV since the arrival of PS3.

    Officially, PS3 is now my entertainment center!

  • Love Marriage

    Recently, I read a blog post from my friend Srikanth on Marriages in India. There was a lot more that I could relate to, so here is my view on it.

    Marriages – In India, this signifies more than the coming together of two people. It is the coming together of two families and relations. It is an event where people want to showcase their position/status to the relations and friends. It means a lot to the parents of both the sides. Each caste/subcaste has its own custom ways of conducting a marriage. There lies the beauty of marriages too, elaborate preparations, sending out invitations, inviting people, booking of marriage halls, cameras, reception, food etc., and the list goes on!

    When it comes to arranged marriages, the process is simple. Everything is arranged. Which also means, everything is taken care of by the parents. This is one last responsibility that every parent wants to handle before considering their children to be mature enough to handle the world! With arranged marriages, everyone is happy, parents, friends, relatives and also the bride and the groom. Happily Ever After!

    In case of love marriages, the process is always complex, excepting in a few rare instances. Nothing is arranged. Since marriages are the coming together of two families, it takes a lot of time. Convincing the parents first to agree to it. If the boy and the girl belong to different caste/subcaste (forget different religions here), there comes the problem for convincing the parents to stop worrying about the society. Then comes the part where both the families have to meet. This is the hardest part. Both families have to like each other 🙂 If all these succeed, then comes the actual negotiation and finally marriage. The thing here is, no one in both the parties will want to hold the responsibility. Everyone will like to escape, to get away from the wrath of the society. So it falls on the heads of the bride and the groom, to do all the consoling and getting everyone to agree.

    One nice thing about love marriages is (as per my understanding), during this entire process, the boy and the girl get to understand and appreciate each other well. This helps in the long run of their relationship. They tend to talk over each and every step. Each one of them start to like the ability of the other to handle tight situations, supporting each other. Fruitful!

    Marriage is the occasion to commemorate the coming together of two people. An event to forget all differences and wish the couple a happy life together! When the life itself is not predictable, why not let people live happily till they are! Let Happiness prevail!

  • Trip Back Home

    Here, I am sitting in the Richmond International Airport waiting for my flight back home. Constantly checking the status of the flights, praying that there are no delays/cancellations.

    It is really a good feeling here. After 10 months of being independent, landing in home ground on the Independence Day! (Aug 15).

    Just packed enough to please all people at home, gifts, toys, music players.. Time to ponder on what happened in the past months here in US.

    I began liking US for what it is! Strict Rules, People following Rules, Cleanliness etc. It doesn’t mean that I hate India for these. I like India as it is! After all, it is my home!

    Learnt to live alone, cooking, washing, travelling, making friends… Transforming from a Dependent Kid at home to the Independent Man.

    Now, awaiting the flight!

  • Google Image Search

    Google is making a lot of improvement on the UI front recently.

    Today, they have improved Image Search with displaying all the search results on a single page. The page displays only the images. On scrolling over the image, details about the page that the image comes from is displayed.

    Improved Image Search on Google

    A welcome improvement!

  • Logi XML BI Tool

    For the current project that I am working on, we were looking for alternatives to the SQL Server Reporting Services. We ended up with a really good BI solution, LogiXML.

    LogiXML is a XML based reporting solution available for .net and Java platforms. More information can be found in their website, www.logixml.com

    To us, it really simplified the way we used to work on reports. It was something similar to the Sagitec Studio, that we use in our work everyday (Sagitec Studio is for Web Development, developed and used as a product by my current employers), which meant lesser learning curve. The AdHoc Reporting capabilities is what caught our attention. It is neat, the LogiXML team has thought through most of the aspects of Reporting.

    All common reporting functions, with an excellent support team. They have always responded quicker. The product is well documented and supported. If I like one reporting tool, it must be LogiXML. Will definitely recommend it to anyone.

  • Social Networking

    For the past one month, I am getting to meet families of my colleagues, having lunch, tea and dinner with them. Socializing!

    This is giving me the break from the monotony of living alone and single in my apartment. Getting to meet people, share thoughts, playing golf, badminton, etc.

    With it, my tummy has again started to grow. Nice food, Indian food, South Indian meals, from Vijay’s, Renga’s, Murali’s and Bhavneet’s houses, travelling on my car, getting used to driving in the nights and the rains. These are those nice things that happened in the past month. I have decided to try every nice restaurant in Richmond, eat the specialty dishes.

    Started off with omelette’s, hash browns and pan cakes in ‘ihop’… More to come…