Type locator issue
Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2012
Forum Discription: For .NET 4.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4109
Printed Date: 10-Apr-2025 at 6:31pm
Topic: Type locator issue
Posted By: smi-mark
Subject: Type locator issue
Date Posted: 11-Apr-2013 at 9:58am
There is a problem in IdeaBlade.Core.TypeWrapper when using two entity types in one projection
I have a projection that has two properties, each from different assemblies. The GetTypeUsingMap() method does not support this. The code that loops through the __userAssemblyMapping dictionary needs to be improved to support this.
This is the error I get:
System.Func`2[[TaxOffice.Model.OwnerAddress, TaxOffice.Model.SL,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null],[SMI.Common.Model.Address, SMI.Common.Model.SL,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib,
Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
I've put a temporary patch in my web server global.asax for now
I ensure that both model assemblies exist in the user mapping by simply checking the TypeWrapper for the objects. I then add a simple entry to the system mapping to replace any Model.SL with Model (which works in my case)
protected void Application_Start(object sender, EventArgs e)
{
System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(new IdeaBlade.EntityModel.Web.ServiceVirtualPathProvider());
AddType("TaxOffice.Model.OwnerAddress, TaxOffice.Model.SL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
AddType("SMI.Common.Model.Address, SMI.Common.Model.SL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
var systemMapping = (Dictionary<string, string>)typeof(TypeWrapper).GetField("__systemAssemblyMapping", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
systemMapping.Add("Model.SL", "Model");
}
public bool AddType(string name)
{
try
{
var wrapper = new TypeWrapper(null);
wrapper.GetType().GetProperty("AssemblyQualifiedName").SetValue(wrapper, name);
wrapper.GetType().GetProperty("IsNull").SetValue(wrapper, false);
return wrapper.Type != null;
}
catch
{
return false;
}
}
|
|
Replies:
Posted By: smi-mark
Date Posted: 11-Apr-2013 at 10:12am
FYI, in my projection this is where the problem is coming from:
PrimaryOwnerAddress = a.AccountOwners.Where(ao => ao.IsPrimary).SelectMany(ao => ao.Owner.OwnerAddresses).Where(oa => oa.IsPrimary).Select(oa => oa.Address).FirstOrDefault(),
|
Posted By: kimj
Date Posted: 11-Apr-2013 at 10:45am
Thanks, Mark. As you know, we have an outstanding bug with type mapping (reported by you with projections - http://www.ideablade.com/forum/forum_posts.asp?TID=3822 - http://www.ideablade.com/forum/forum_posts.asp?TID=3822 ). We'll bump up the priority to get this fixed in a near future release. Glad you found a workaround for now.
|
Posted By: smi-mark
Date Posted: 11-Apr-2013 at 10:52am
Yea, this is similar to the other issue except even if the assembly names are the same it will still fail, as it uses two different assemblies. We have just switched to code first for most of our projects, so that's why we're only finding this now. We will never go back to that EDMX designer again :)
|
Posted By: kimj
Date Posted: 30-Apr-2013 at 5:58pm
Mark, these type locator issues have been fixed in the 7.1.2 release.
|
|