Linq To SQL and multiple foreign keys naming issue

L

Lothar Behrens

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
 
M

Mr. Arnold

Lothar said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top