Is it suggestable to use generics for large amount of data?

I'm not really sure how generics ties into data-volume; they are unrelated concepts... it also isn't clear to me why this requires you to read everything twice. But yes: generics are fine when used in volume (why wouldn't they be? ).

But of course, the best way to find a problem is profiling (either server performance or bandwidth - perhaps more the latter in this case) Of course the better approach is: don't show thousands of records on a web form; what is the user going to do with that? Use paging, searching, filtering, ajax, etc - every trick imaginable - but don't send thousands of records to the client Re the updated question; the loop for setting properties isn't necessarily bad. This is an entirely appropriate inner loop.

Before doing anything, profile to see if this is actually a problem. I suspect that sheer bandwidth (between server and client, or server and database) is the biggest issue. If you can prove that this loop is a problem there are things you can do do optimise: switch to using PropertyDescriptor (rather than PropertyInfo ), and use HyperDescriptor to make it a lot faster write code with DynamicMethod to do the job - requires some understanding of IL, but very fast write a .

NET 3.5 / LINQ Expression to do the same and use Compile() like the second point, but (IMO) a bit easier I can add examples for the first and third bullets; I don't really want to write an example for the second, simply because I wouldn't write that code myself that way any more (I'd use the 3rd option where available, else the 1st).

I'm not really sure how generics ties into data-volume; they are unrelated concepts... it also isn't clear to me why this requires you to read everything twice. But yes: generics are fine when used in volume (why wouldn't they be? ).

But of course, the best way to find a problem is profiling (either server performance or bandwidth - perhaps more the latter in this case). Of course the better approach is: don't show thousands of records on a web form; what is the user going to do with that? Use paging, searching, filtering, ajax, etc - every trick imaginable - but don't send thousands of records to the client.Re the updated question; the loop for setting properties isn't necessarily bad.

This is an entirely appropriate inner loop. Before doing anything, profile to see if this is actually a problem. I suspect that sheer bandwidth (between server and client, or server and database) is the biggest issue.

If you can prove that this loop is a problem there are things you can do do optimise: switch to using PropertyDescriptor (rather than PropertyInfo), and use HyperDescriptor to make it a lot faster write code with DynamicMethod to do the job - requires some understanding of IL, but very fast write a . NET 3.5 / LINQ Expression to do the same and use .Compile() - like the second point, but (IMO) a bit easier I can add examples for the first and third bullets; I don't really want to write an example for the second, simply because I wouldn't write that code myself that way any more (I'd use the 3rd option where available, else the 1st).

1 +1. I remember a client requirement that wanted to show all records returned from searches...until it was pointed out "what are end usesr going to do with several million rows! (never mind the load on server)" – Mitch Wheat Sep 24 '09 at 11:50 In Datareader, I required to loop through twice because one loop is for actual records & another inner for no of properties.

This looping is for setting datareader's value to List. Second point is acceptible, I can lesser down the records but how can I avoid looping? Thanks for quick reply.

– Laxman Sep 24 '09 at 11:53 @Laxman - do you mean how many properties have a value? – Russ Cam Sep 24 '09 at 12:03 Russ, Please find the updated example for my question.. – Laxman Sep 24 '09 at 12:25.

It is very difficult what to say the performance will be, but consider these things - Generics provides type saftey If you're going to display 10,000 records in the page, your application will probably be unusable. If records are being paged, consider returning only those records that are actually needed for the page you are on. You shouldn't need to loop through the data twice.

What are you doing with the data?

I'm not really sure how generics ties into data-volume; they are unrelated concepts... it also isn't clear to me why this requires you to read everything twice. But yes: generics are fine when used in volume (why wouldn't they be?). But of course, the best way to find a problem is profiling (either server performance or bandwidth - perhaps more the latter in this case).

Of course the better approach is: don't show thousands of records on a web form; what is the user going to do with that? Use paging, searching, filtering, ajax, etc - every trick imaginable - but don't send thousands of records to the client. Re the updated question; the loop for setting properties isn't necessarily bad.

This is an entirely appropriate inner loop.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions