To answer the question (instead of recommending an ORM), the fastest way is what you have already illustrated with the couple of lines of code. Those lines are quite brittle code, but if you eliminate DbNull checks and TryParse or Parse operations, and use column ordinals instead of column names, then the code can't get much faster or more direct Of course if you are going to take this approach then you had better make sure that your database code is absolutely bulletproof and returns items in exactly the right order, with values that are appropriate (i.e. No null values in columns that will be assigned to value types back in the C# code).
Needless to say this sort of code is not very maintainable long term.
To answer the question (instead of recommending an ORM), the fastest way is what you have already illustrated with the couple of lines of code. Those lines are quite brittle code, but if you eliminate DbNull checks and TryParse or Parse operations, and use column ordinals instead of column names, then the code can't get much faster or more direct. Of course if you are going to take this approach then you had better make sure that your database code is absolutely bulletproof and returns items in exactly the right order, with values that are appropriate (i.e.No null values in columns that will be assigned to value types back in the C# code).
Needless to say this sort of code is not very maintainable long term...
Thank you slugster that was really helpful, nulls will be handled at query level. – Damien Joe Apr 21 at 9:33.
Take a look at the Dapper project as a lightweight ORM implementation. It was actually developed by (and for) StatOverflow as far as I know.
Thanks, will have a look. – Damien Joe Apr 20 at 11:06.
If you are using data reader then your way is the good way apart from the fact that you can use null checking for columns that could be null. The fastest way would be the one that uses column indices instead of names. The best way would be to create a T4 template that would operate on some data-dictionary (perhaps xml file) to generate fastest code for both DTO and to fill those DTO.
Edit: Oh! - I forgot - the recommended way would be to use some O/R mapper framework and do not worry too much about such mundane details!
Entity Framework and ADO. NET are your friends. If you want to tweak it later on, learn T4 and write your own templates, you can write stuff like: Standart CRUD WCF web services Cloning etc.
To answer the question (instead of recommending an ORM), the fastest way is what you have already illustrated with the couple of lines of code. Those lines are quite brittle code, but if you eliminate DbNull checks and TryParse or Parse operations, and use column ordinals instead of column names, then the code can't get much faster or more direct. Of course if you are going to take this approach then you had better make sure that your database code is absolutely bulletproof and returns items in exactly the right order, with values that are appropriate (i.e.
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.