A linq query that returns an anonymous type throws the following error when executed.
The type '<>f__AnonymousType9<Name,Value>' exists in both
'Customer.CustomerWeb.Presentation.dll' and 'Customer.CustomerContext.dll'
Using JetBrains dotPeek
I was able to find that there is are 2 compiler generated classes that collide.
Customer.CustomerContext.dll
internal sealed class <>f__AnonymousType9<<PayrollSiteID>j__TPar, <IsActive>j__TPar>
Customer.CustomerWeb.Presentation.dll
internal sealed class <>f__AnonymousType9<<Name>j__TPar, <Value>j__TPar>
Both of the generated classes are in the root namespace
. Is there any way I can direct Anonymous Type classes
to a particular namespace on each assembly? The easy fix is to add a third variable to one of the anonymous queries, however this is more of a hack.
Anonymous types are class types that derive directly from object , and that cannot be cast to any type except object . The compiler provides a name for each anonymous type, although your application cannot access it.
Anonymous types in C# are the types which do not have a name or you can say the creation of new types without defining them. It is introduced in C# 3.0. It is a temporary data type which is inferred based on the data that you insert in an object initializer.
When specifying multiple properties use an anonymous type: C#: 't => new { t. MyProperty1, t. MyProperty2 }' VB.Net: 'Function(t) New With { t. MyProperty1, t.
I think you want something like the following, where you add your using statement inside the namespace to give it preference in name resolution:
using Customer.CustomerContext;
namespace yourNameSpace
{
using Customer.CustomerWeb.Presentation; //Where f__AnonymousType9<Name,Value> exists
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With