Page 1 of 1
Any .NET (c#) guru's here???
Posted: Thu Mar 03, 2011 8:34 pm
by okemos
Any C# sharp guru in this forum? I have a technical question.
Any .NET (c#) guru's here???
Posted: Thu Mar 03, 2011 8:36 pm
by Sai_R2I
There is a member with handle dotnetguru, I think.. :))
It would help if you throw the question out here..
Any .NET (c#) guru's here???
Posted: Thu Mar 03, 2011 8:42 pm
by okemos
Sai_R2I;373738There is a member with handle "dotnetguru", I think..
Anyway, throw the question at us(/them) and then we(/they) will figure out, if we(/they) are guru or not :))
Looks like you can answer this. Anyway here is the problem.
There is an Employee object (class), one of the attributes is "Salary"
There is a List Array containing storing multiple employee objects.
Eg: statement is
List allEmployees = new List(); Question is: How do i get the total salary paid to all employees and also the highest paid employee? What is the quickest and best possible way to retrieve this information?
Any .NET (c#) guru's here???
Posted: Thu Mar 03, 2011 9:02 pm
by Sai_R2I
^^
The first solution that pops into my head(other than the routine iterative thingie) would be - handling it on database side is a faster route for such computations.
If it has to be an in-memory object, can LINQ be of help?
[QUOTE]When using LINQ with any supported data source (in-memory, relational data, XML) we can make use of a set of a standard query operators which empower us to manipulate our data source more effectively.
http://dotnetslackers.com/articles/csharp/IntroducingLINQ1.aspx
Disclaimer: I am a Java Pro and DotNet Rookie..Sorry, if this is not of much help
Any .NET (c#) guru's here???
Posted: Thu Mar 03, 2011 9:09 pm
by okemos
Sai_R2I;373749^^
The first solution that pops into my head(other than the routine iterative thingie) would be - handling it on database side is a faster route for such computations.
If it has to be an in-memory object, can LINQ be of help?
http://dotnetslackers.com/articles/csharp/IntroducingLINQ1.aspx
Disclaimer: I am a Java Pro and DotNet Rookie..Sorry, if this is not of much help
I do not want to use SQL Query in DB to retrieve the value. Also traditional iterative process will be cumbersome if the list array is huge. I haven't tried LINQ. Let me check this link.
Thanks Nanba.
Any .NET (c#) guru's here???
Posted: Thu Mar 03, 2011 9:12 pm
by Sai_R2I
okemos;373750
Thanks Nanba.
Ahem - Nanbi :) :-))
Glad to be of any help, Boss - Also, would suggest pinging dotnetguru and getting his input as well. I can't remember any other .Net person in the forum.
Any .NET (c#) guru's here???
Posted: Thu Mar 03, 2011 9:17 pm
by okemos
Sai_R2I;373752Ahem - Nanbi :) :-))
Glad to be of any help, Boss
Nanbi??? I didn't know that. Anyway thanks Nanbi.
Never tried LINQ. Let me see how it goes.
Any .NET (c#) guru's here???
Posted: Thu Mar 03, 2011 9:41 pm
by rajubiztech
okemos;373750I do not want to use SQL Query in DB to retrieve the value. Also traditional iterative process will be cumbersome if the list array is huge. I haven't tried LINQ. Let me check this link.
Thanks Nanba.
I believe simple loop performs better than LINQ at runtime for calculations.
Any .NET (c#) guru's here???
Posted: Thu Mar 03, 2011 10:46 pm
by okemos
rajubiztech;373763I believe simple loop performs better than LINQ at runtime for calculations.
Yes, simple loop or issuing a direct sql query using datareader would solve this issue. If the dataset is too large then we may need to compromise on the performance side.
Any .NET (c#) guru's here???
Posted: Thu Mar 03, 2011 11:11 pm
by rajaR2I
okemos;373750I do not want to use SQL Query in DB to retrieve the value. Also traditional iterative process will be cumbersome if the list array is huge. I haven't tried LINQ. Let me check this link.
Thanks Nanba.
Is there any specific reason you don't want to retrive the value from SQL? If you are filling your list from DB already, cann't you bring the calculated value as well at that time?