{"action":"created","issue":{"url":"https://api.github.com/repos/OData/odata.net/issues/143","labels_url":"https://api.github.com/repos/OData/odata.net/issues/143/labels{/name}","comments_url":"https://api.github.com/repos/OData/odata.net/issues/143/comments","events_url":"https://api.github.com/repos/OData/odata.net/issues/143/events","html_url":"https://github.com/OData/odata.net/issues/143","id":65520427,"number":143,"title":"ValidatePropertyDefined requires that no OpenType properties exist.","user":{"login":"AdamCaviness","id":534790,"avatar_url":"https://avatars.githubusercontent.com/u/534790?v=3","gravatar_id":"","url":"https://api.github.com/users/AdamCaviness","html_url":"https://github.com/AdamCaviness","followers_url":"https://api.github.com/users/AdamCaviness/followers","following_url":"https://api.github.com/users/AdamCaviness/following{/other_user}","gists_url":"https://api.github.com/users/AdamCaviness/gists{/gist_id}","starred_url":"https://api.github.com/users/AdamCaviness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdamCaviness/subscriptions","organizations_url":"https://api.github.com/users/AdamCaviness/orgs","repos_url":"https://api.github.com/users/AdamCaviness/repos","events_url":"https://api.github.com/users/AdamCaviness/events{/privacy}","received_events_url":"https://api.github.com/users/AdamCaviness/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-31T18:48:37Z","updated_at":"2015-04-01T12:41:36Z","closed_at":null,"body":"We are trying to add OpenType support to one of our entities.  On .NET client using OData Client with OData Client Code Generator proxies we would like to send up ODataProperties for each of our dynamic properties that are modified on the client.  Microsoft.OData.Core.WriterValidationUtils.ValidatePropertyDefined() does not allow this even though the type is an OpenType.  \r\n> The property 'Description' does not exist on type 'WhateverNamespace.WhateverModel'. Make sure to only use property names that are defined by the type. \r\n\r\nThere may be a [related issue](https://github.com/OData/odata.net/issues/134)."},"comment":{"url":"https://api.github.com/repos/OData/odata.net/issues/comments/88465113","html_url":"https://github.com/OData/odata.net/issues/143#issuecomment-88465113","issue_url":"https://api.github.com/repos/OData/odata.net/issues/143","id":88465113,"user":{"login":"AdamCaviness","id":534790,"avatar_url":"https://avatars.githubusercontent.com/u/534790?v=3","gravatar_id":"","url":"https://api.github.com/users/AdamCaviness","html_url":"https://github.com/AdamCaviness","followers_url":"https://api.github.com/users/AdamCaviness/followers","following_url":"https://api.github.com/users/AdamCaviness/following{/other_user}","gists_url":"https://api.github.com/users/AdamCaviness/gists{/gist_id}","starred_url":"https://api.github.com/users/AdamCaviness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdamCaviness/subscriptions","organizations_url":"https://api.github.com/users/AdamCaviness/orgs","repos_url":"https://api.github.com/users/AdamCaviness/repos","events_url":"https://api.github.com/users/AdamCaviness/events{/privacy}","received_events_url":"https://api.github.com/users/AdamCaviness/received_events","type":"User","site_admin":false},"created_at":"2015-04-01T12:41:36Z","updated_at":"2015-04-01T12:41:36Z","body":"@LaylaLiu Thanks for the response.  I had already did that as a workaround but it is very constricting because A) I have to know what all the dynamic properties might be.  B) I have to maintain those over time.  Open Types provide a way to use dynamic properties, I don't want to use static properties on the client.  \r\n\r\nHere is what I'm doing.  For some time I've had the OData Client code ingested as a project in my solution so I can handle a few special cases.  Regarding having dynamic properties on the client, I've added the following code to EntryValueMaterializationPolicy.MaterializeResolvedEntry\r\n\r\n```CSharp\r\nforeach (var e in entry.Properties)\r\n{\r\n\tif (e.Value is ODataStreamReferenceValue)\r\n\t{\r\n\t\tcontinue;\r\n\t}\r\n\r\n\tvar prop = actualType.GetProperty(e.Name, this.MaterializerContext.IgnoreMissingProperties);\r\n\tif (prop == null)\r\n\t{\r\n\t\t// ***********************************************\r\n\t\t// Support OData Open Types.\r\n\t\t// If the property has no destination, stick it in the DynamicProperties dictionary.\r\n\t\tvar openType = entry.ResolvedObject as IOpenType;\r\n\t\tif (openType != null)\r\n\t\t{\r\n\t\t\tif (!openType.DynamicProperties.ContainsKey(e.Name))\r\n\t\t\t\topenType.DynamicProperties.Add(e.Name, e.Value);\r\n\t\t\telse\r\n\t\t\t\topenType.DynamicProperties[e.Name] = e.Value;\r\n\t\t}\r\n\t\t// ***********************************************\r\n\r\n\t\tcontinue;\r\n\t}\r\n\r\n\tif (entry.ShouldUpdateFromPayload)\r\n\t{\r\n\t\tValidatePropertyMatch(prop, e, this.MaterializerContext.Model, true /*performEntityCheck*/);\r\n\r\n\t\tthis.ApplyDataValue(actualType, e, entry.ResolvedObject);\r\n\t}\r\n}\r\n```\r\nThe little IOpenType interface:\r\n```CSharp\r\nusing System;\r\nusing System.Collections.Generic;\r\n\r\nnamespace Microsoft.OData.Client\r\n{\r\n\tpublic interface IOpenType\r\n\t{\r\n\t\t/// <summary>\r\n\t\t/// Gets the dynamic properties using the same likeness of \r\n\t\t/// dynamic properties on the OData server.  It is expected \r\n\t\t/// that the DataServiceContext implementation not send this back to the server.\r\n\t\t/// </summary>\r\n\t\t/// <value>\r\n\t\t/// The dynamic properties.\r\n\t\t/// </value>\r\n\t\tDictionary<string, object> DynamicProperties { get; }\r\n\t}\r\n}\r\n```\r\n\r\nSo this gives me a dictionary of the same likeness of the model on the server.  Then in my derived DataServiceContext I hook OnEntryStarting:\r\n```CSharp\r\nConfigurations.RequestPipeline.OnEntryStarting(ea => EntryStarting(ea));\r\n```\r\nand then for every IOpenType entity, I create an ODataProperty and send that back up to the server.\r\n```CSharp\r\n\tif (entityState == EntityStates.Modified || entityState == EntityStates.Added)\r\n\t{\r\n\t\tvar odataProps = i.Entry.Properties as List<ODataProperty>;\r\n\t\tif (odataProps == null)\r\n\t\t\todataProps = new List<ODataProperty>(i.Entry.Properties);\r\n\r\n\t\t// I have other code here to remove any transient properties that should\r\n\t\t// not go back up to the server by using a TransientPropertyAttribute.  The \r\n\t\t// DynamicProperties property in the given partial model is marked as a \r\n\t\t// TransientProperty and removed from odataProps.\r\n\r\n\t\t// Send up Open Type dynamic properties.\r\n\t\tif (entity is IOpenType)\r\n\t\t{\r\n\t\t\tforeach (var dynamicProperty in ((IOpenType)entity).DynamicProperties)\r\n\t\t\t{\r\n\t\t\t\tvar odataProperty = new ODataProperty() { Name = dynamicProperty.Key, Value = dynamicProperty.Value };\r\n\t\t\t\todataProps.Add(odataProperty);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\ti.Entry.Properties = odataProps;\r\n```\r\n\r\n\r\nThis would all be a very satisfactory solution to dynamic properties on the client if it were not for the issue mentioned at the beginning.  Microsoft.OData.Core.WriterValidationUtils.ValidatePropertyDefined should allow for sending ODataProperties up that were never on the model."}}