acmedeepak,
In order to help you we need more information along with some sample data and expected output.
We also don't know how you have translated the query output to the C# names. W/O that we can't determine what code would be able to replace the C# code.
Regards,
Matt