Namespaces

M

meyousikmann

I am just learning C# so excuse the simplicity of this question. I work at
Seagate Technology and I want to be able to create a .NET assembly specific
to our Oracle database. I want to do something like this:

using System;

namespace Seagate.Oracle
{
/// <summary>
/// Summary description for Connection.
/// </summary>
public class Connection
{
public Connection()
{
//
// TODO: Add constructor logic here
//
}

public static void Open()
{
}
}
}

Now, I am also using Oracle's ODP.NET data provider and I want to be able to
reference classes from the Oracle.DataAccess.Client namespace within my
Seagate.Oracle namespace, but it doesn't work. Whenever I want to reference
a class from the Oracle.DataAccess.Client namespace, it always resolves to
Seagate.Oracle first. For example, I would like the Open method to look
like this:

public static void Open(Oracle.DataAccess.Client.OracleConnection conn)

but as soon as I type Oracle. it resolves to Seagate.Oracle instead of
Oracle.DataAcess.Client and the autocomplete wants to finish the statement
as Seagate.Oracle.Connection. Is there a way to reference the
Oracle.DataAccess.Client namespace from within the Seagate.Oracle namespace
without me having to change the name of my namespace to be different than
the Oracle namespace?

Oh and yes, I have added the reference to Oracle.DataAccess.Client to my
project.

Any help is greatly appreciated.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


I think you have two options:
1- Either reference the classes with the fully quilified name (
Oracle.DataAccess.Client.Connection )
or just an alias for the namespace

cheers,
 
M

meyousikmann

Even using the fully qualified name doesn't solve the problem. Since Oracle
is part of the namespace Seagate.Oracle, the word Oracle will always resolve
to Seagate.Oracle instead of Oracle.DataAcess....... I was hoping there was
a way to force the namespace resolution to go outside of the local namespace
but there doesn't seem to be a way.

A solution to the problem was given by the previous responder as well as
yourself in suggesting an alias. I have used an alias for the namespace
Oracle.DataAcess.Client and that works fine.

Thanks for the response.
 
M

meyousikmann

Yep, aliases solved the problem. I was hoping for a more direct approach to
force the namespace resolution outside of the Seagate.Oracle namespace, but
apparently there is no way to do that.

Thanks for the response.
 
J

Jon Skeet [C# MVP]

meyousikmann said:
Even using the fully qualified name doesn't solve the problem. Since Oracle
is part of the namespace Seagate.Oracle, the word Oracle will always resolve
to Seagate.Oracle instead of Oracle.DataAcess....... I was hoping there was
a way to force the namespace resolution to go outside of the local namespace
but there doesn't seem to be a way.

A solution to the problem was given by the previous responder as well as
yourself in suggesting an alias. I have used an alias for the namespace
Oracle.DataAcess.Client and that works fine.

Thanks for the response.

Note that in C# 2.0, you could use global::Oracle.DataAccess etc.
 

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

Top