Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ambiguous reference between two namespaces

Tags:

.net

asp.net

linq

I am getting the following error

Error 36 'SLICDataContext' is an ambiguous reference between 'SLIC_DataAccess.SLICDataContext' and 'SLIC_DataAccess.Generic.SLICDataContext' CreateRequest.aspx.cs 48 36 C:...

Code:

int num = (
    from x in (new SLICDataContext()).ClientsToPriorities
        where x.PriorityID == Convert.ToInt32(this.drpPriority.SelectedValue)
        where x.ClientID == this.GetClientID
    select x.ClientToPriorityID).Single<int>();
return num;

Namespaces I am using

using SLIC_DataAccess.Generic;
using SLIC_DataAccess;

How can I be more specific in referencing the namespaces in my code to resolve this?

like image 707
Hakan Zim Avatar asked Dec 10 '25 09:12

Hakan Zim


2 Answers

You need to fully qualify your class in your code using the applicable namespace.

Depending on the implementation, it will be one of these:

from x in (new SLIC_DataAccess.Generic.SLICDataContext()).ClientsToPriorities

or

 from x in (new SLIC_DataAccess.SLICDataContext()).ClientsToPriorities

Another option would be to use aliases as follows:

using SLIC_DA_Generics = SLIC_DataAccess.Generic;
using SLIC_DA = SLIC_DataAccess;

with the appropriate usage as follows:

from x in (new SLIC_DA_Generics.SLICDataContext()).ClientsToPriorities

or

from x in (new SLIC_DA.SLICDataContext()).ClientsToPriorities
like image 153
jordanhill123 Avatar answered Dec 13 '25 01:12

jordanhill123


You can explicitly say which namespace you wish to use, for example:

from x in (new SLIC_DataAccess.Generic.SLICDataContext()).ClientsToPriorities
like image 45
Andrew Avatar answered Dec 13 '25 02:12

Andrew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!