/// <Summary> /// obtain the list (any entity, as few fields as possible) /// </Summary> /// <typeparam name = "T"> </typeparam> /// <Param name = "SQL"> </param> /// <returns> </returns> Public static list <t> findlistbysql <t> (string SQL, string dbname) where T: New () {list <t> List = new list <t> (); object OBJ; idatareader RD = NULL; try {RD = runreader (SQL, dbname); If (typeof (t) = typeof (INT) {While (Rd. read () {list. add (t) RD [0]);} e LSE if (typeof (t) = typeof (string) {While (Rd. read () {list. add (t) RD [0]) ;}} else {ilist propertylist = reflectionutil. getpropertylist (typeof (t); int fcnt = RD. fieldcount; List <string> fileds = new list <string> (); For (INT I = 0; I <fcnt; I ++) {fileds. add (Rd. getname (I ). toupper ();} while (Rd. read () {idatarecord record = RD; OBJ = new T (); foreach (propertyinfo pro in propertylist) {I F (! Fileds. contains (Pro. name. toupper () | record [pro. name] = dbnull. value) {continue;} If (rft. isinterface (Pro. propertytype, typeof (ientity) {If (record [pro. name]. getType () = typeof (INT) {ientity subojb = NDB. findbyid (Pro. propertytype, (INT) record [pro. name]); If (rft. isinterface (obj. getType (), typeof (ientity) {(ientity) OBJ ). set (Pro. name, subojb);} else {pro. setvalue (OBJ, convert. changet Ype (subojb, Pro. propertytype), null) ;}} else {pro. setvalue (OBJ, record [pro. Name] = dbnull. value? Null: getreadervalue (record [pro. name], pro. propertytype), null) ;}} list. add (t) OBJ) ;}} catch (exception ex) {logger. error ("SQL =>" + SQL); logger. error (ex. message); logger. error (ex. stacktrace); throw ex;} finally {If (RD! = NULL &&! Rd. isclosed) {RD. Close () ;}} return list ;}
View code
Start with the above Code.
This code was written by our project manager. After reading it for a while, I learned the logic in it, but the Code cannot be debugged, but it is not very thorough.
After reading this code, I feel that the technical gap between my project manager and I is here. Although I can understand it, I can write it out after the study, but the level is not here. Our project uses a third-party MVC Framework. In some cases, this function does not directly use C # To reflect related classes, but uses classes encapsulated in the framework, the project manager did not write a piece of code on his own, but wrote it on the basis of understanding the framework. The Project Manager cannot have a lot of free time to study the framework, which can be at most a few weeks. Understand a third-party framework in a short period of time and expand what is needed on the basis of it. This is what reflects the level! It is also a technical capability that I do not possess now.
I have written some relatively technical things before, but they have a feature that is 100% original. Even if someone else has something, I will rewrite it, become your own. Chinese people have an advantage, especially good at reverse engineering. Why can't I have this advantage! I think technically, the company needs such a person, a new project, and a new framework, but the framework is not perfect and there are limitations. Can you do it before other employees start work, in just a short period of time, what is missing in the framework, what needs to be improved, or what needs to be modified according to the actual needs of the project?
Yesterday, I watched the code I wrote when I graduated in 2010. The code was really bad. It was so crazy! However, as an employee who just graduated, as long as there is no deviation in the design of the leadership, the project will not fail because of my bad code. When I see the code, I think the project manager is somewhat negligent? Code review for employees is still very important, especially for employees who have not been working for a long time. But then again, it is these bad, crazy, and ignorant code that makes it easy for me to write this kind of code. Later, I felt that I had gone astray, So I no longer wrote such code, became regular, and no longer took risks. I also stopped here!
Why can't I reach the project manager level? In addition to my understanding, I have not been involved in the framework, and I have not written a lot of bad code as I used to write the page function. I don't have a few bad frameworks, but I don't have a few bad projects. How can the level come up?
Looking back at the code above, in the eyes of a better expert (I forgot to use words), I actually felt nothing after reading it. But without this code, I'm afraid I can't write it, or I don't even know how to write it. It may mean that the project needs to write a lot more code. (September 6, 2014 00:05) (September 6, 2014 01:54)
Ways of progress