Scott Marshall
Scott Marshall

Reputation: 169

namespace and table sharing the same name (oops!)

First - I admit to my mistake!

But I need to know if I should try to fix it, or just live with the consequences.

I created a new solution (C#, VS2010) - let's call it 'F.PIA', for ease of reference. One of the things this solution does is work with a SQL Server table that - yep, you guessed it - is also named 'PIA'. So everything about my project - including the main namespace - is F.PIA.

I'm using F.A.PIA, to access the PIA table; this assembly includes a Table and a public partial class PIA.

In my solution, I can distinguish the two, but I find references to F.A.PIA to be clumsy (the actual names are significantly longer than that example).

So I tried to Refactor, w/o success. I'm pretty sure the renaming changes something in the DataSetDesigner, or doesn't change something there (or a related item) - but I'm not nearly proficient enough to figure out what, exactly, goes wrong - nor how to fix it. (Yes, I did have a working backup before the Refactor - YAY.)

Should I just leave it as is, and learn from my mistake for next time? or is there a way to rename everything except the references to my table, and get everything to behave?

Thanks! -- Scott M

Upvotes: 4

Views: 229

Answers (1)

ΩmegaMan
ΩmegaMan

Reputation: 31616

Options:

  1. Create namespace alias for the C# namespace by the using directive.
  2. Create a class wrapper which handles the PIA table and provides a more user friendly way of accessing that table.
  3. Fully quailify the namespace items for the C# namespace.
  4. Rename the table, refactor, then change the name back.
  5. Create a new solution which does not have the naming collisions.
  6. Live with the idiosyncrasis as is...

Upvotes: 2

Related Questions