Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception with using Breeze Sharp BaseComplexObject with Web API OData v4 #7

Open
scott-mcdonald opened this issue Aug 31, 2014 · 0 comments

Comments

@scott-mcdonald
Copy link

Background: I wanted to give Breeze Sharp on the client side a spin as I have "finished" with putting together an WebApi OData v4 service and wanted to start focusing on the client side, etc.

So after reading the website I believe I need to do the following:

  1. All my entity classes need to implement IEntity.
  2. All my complex object classes need to implement IComplexObject.

So the "data model" I put in a PCL class library that used Profile 78 where this assembly is shared both on the client and server side as essentially the shared "data model". I decided to first convert my "complex objects" to Breeze Sharp by inheriting from BaseComplexObject, change the property getter/setter to use the GetValue/SetValue respectively, etc.

Here is just 1 simple example:

[DataContract(Namespace = Constants.DataContractNamespace)]
public class GeoCoordinate : BaseComplexObject
{
    #region Properties
    [DataMember(Order = 0)]
    public double Latitude
    {
        get { return this.GetValue<double>(); }
        set { this.SetValue(value); }
    }

    [DataMember(Order = 1)]
    public double Longitude
    {
        get { return this.GetValue<double>(); }
        set { this.SetValue(value); }
    }
    #endregion
}

After all this I wanted to rebuild all and see what happens, if anything breaks, etc. Everything built but when I went to try the web api odata v4 service I would get the following error (note this error happened only after I introduced Breeze Sharp as described above):

Note also I am using the ODataConventionModelBuilder (WebApi OData v4 version of it)
private static IEdmModel GetModel()
{
var builder = new ODataConventionModelBuilder();
...
builder.EntitySet("Buildings");
...
builder.EntitySet("Users");

        // Configure ContentData to be contained by Content.
        var contentDataType = builder.EntityType<ContentData>();
        contentDataType.HasKey(x => x.ContentId);

        builder.EntityType<Content>().ContainsRequired(x => x.ContentData);

        // Property names in the EDM model will become camel cased.
        builder.EnableLowerCamelCase();

        return builder.GetEdmModel();
    }

Server Error in '/' Application.

Found more than one dynamic property container in type 'ComplexAspect'. Each open type must have at most one dynamic property container.
Parameter name: propertyInfo

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Found more than one dynamic property container in type 'ComplexAspect'. Each open type must have at most one dynamic property container.
Parameter name: propertyInfo

Source Error:

Line 49: builder.Namespace = "Acme.ProxContent.Models";
Line 50:
Line 51: return builder.GetEdmModel();
Line 52: }
Line 53: }

Source File: c:\Examples\Acme\Source\Acme.ProxContent.ApiServer\App_Start\WebApiConfig.cs Line: 51

Stack Trace:

[ArgumentException: Found more than one dynamic property container in type 'ComplexAspect'. Each open type must have at most one dynamic property container.
Parameter name: propertyInfo]
System.Web.OData.Builder.StructuralTypeConfiguration.AddDynamicPropertyDictionary(PropertyInfo propertyInfo) +711
System.Web.OData.Builder.ODataConventionModelBuilder.MapComplexType(ComplexTypeConfiguration complexType) +146
System.Web.OData.Builder.ODataConventionModelBuilder.MapType(StructuralTypeConfiguration edmType) +86
System.Web.OData.Builder.ODataConventionModelBuilder.AddComplexType(Type type) +31
System.Web.OData.Builder.ODataConventionModelBuilder.ReconfigureEntityTypesAsComplexType(EntityTypeConfiguration[] misconfiguredEntityTypes) +189
System.Web.OData.Builder.ODataConventionModelBuilder.MapComplexType(ComplexTypeConfiguration complexType) +249
System.Web.OData.Builder.ODataConventionModelBuilder.MapType(StructuralTypeConfiguration edmType) +86
System.Web.OData.Builder.ODataConventionModelBuilder.AddComplexType(Type type) +31
System.Web.OData.Builder.ODataConventionModelBuilder.ReconfigureEntityTypesAsComplexType(EntityTypeConfiguration[] misconfiguredEntityTypes) +189
System.Web.OData.Builder.ODataConventionModelBuilder.RediscoverComplexTypes() +142
System.Web.OData.Builder.ODataConventionModelBuilder.GetEdmModel() +124
Acme.ProxContent.ApiServer.WebApiConfig.GetModel() in c:\Examples\Acme\Source\Acme.ProxContent.ApiServer\App_Start\WebApiConfig.cs:51
Acme.ProxContent.ApiServer.WebApiConfig.Register(HttpConfiguration config) in c:\Examples\Acme\Source\Acme.ProxContent.ApiServer\App_Start\WebApiConfig.cs:26
Acme.ProxContent.ApiServer.WebApiApplication.Application_Start(Object sender, EventArgs e) in c:\Examples\Acme\Source\Acme.ProxContent.ApiServer\Global.asax.cs:18

[HttpException (0x80004005): Found more than one dynamic property container in type 'ComplexAspect'. Each open type must have at most one dynamic property container.
Parameter name: propertyInfo]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9905705
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Found more than one dynamic property container in type 'ComplexAspect'. Each open type must have at most one dynamic property container.
Parameter name: propertyInfo]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9885060
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34009

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant