From: Lothar Behrens on 9 Apr 2010 10:54 Hi, I have two tables and one points to the other with three foreign keys, but with different names. The Linq To SQL designer generates integer fields for the foreign keys with a meaningful name, but the object instance with one row of the referenced table has not a well meaning name. Sample: Table Object -> Table Customer Col CustBuy -> id Col CustSell -> id The generated code has integer fields like these: int? CustBuy; int? CustSell; But not meaningful names for the objects: Customer Customer1; Customer Customer2; When using that in code, one doesn't well understand the code when using the object names. How could I change this 'rule to generate code' to say getting this code?: int? CustBuy; int? CustSell; But not meaningful names for the objects: Customer oCustBuy; Customer oCustSell; Then it would be easy to understand the generated code and it will be easy to work with it. II have renamed the objects in the dbml model and then I got meaningful code, but then I am unable to reverse engineer from the SQL server as I have modified my changes in SQL server and not in the DBML. Any thougths? How to model and forward engineer (I haven't determined how this would work)? Thanks Lothar
From: Mr. Arnold on 9 Apr 2010 16:11 Lothar Behrens wrote: > Then it would be easy to understand the generated code and it will be > easy to work with it. You're not suppose to be there. > > II have renamed the objects in the dbml model and then I got > meaningful code, but then I am unable > to reverse engineer from the SQL server as I have modified my changes > in SQL server and not in the DBML. Then you update the model so that it picks-up any changes made to the database. > > Any thougths? > Why are you in the generated code doing anything is the question? You're not suppose to be in the generated code doing anything. But yet, I see this time and time again where a developer using Linq-2-SQL feels the need that he or she must mess with the generated code, which leads to nothing but trouble. I doubt that any developer would be in the generated code generated by the ADO.NET Entity Framework. I guess this must be some kind of lack of overall experience and knowledge of ORM solutions that one goes to Linq-2-SQL and start messing with the generated code.
|
Pages: 1 Prev: Hand made method injection and prop.injection Next: Read Exchange transaction log file |