1
Vote

cannot add xml content in the metadata of an entity object

description

Hi.
I would like to store some xml multiline data in the metadatobject of an entity within the designer.
But the generated code produces something like this :

[nHydrate.EFCore.Attributes.CustomMetadata(Key = "metadata", Value = "<PartyClass>
<UiControl />
<AllowOrganization>False</AllowOrganization>
"

which will not compile .
The solution is simple.
Just add a @ symbol in from of the string ... Value = @"<PartyClass>
and it compiles.
I made the change in the template EntityGeneratedTemplate.cs
foreach (var meta in _item.MetaData)
            {
                // have added to @ sign below in + "\", Value = @\"" +  to be able to add xml metadata in metadata object in generated code
            
                sb.AppendLine(" [nHydrate.EFCore.Attributes.CustomMetadata(Key = \"" + StringHelper.ConvertTextToSingleLineCodeString(meta.Key) + "\", Value = @\"" + meta.Value.Replace("\"", "\\\"") + "\")]");
            //  sb.AppendLine(" [nHydrate.EFCore.Attributes.CustomMetadata(Key = \"" + StringHelper.ConvertTextToSingleLineCodeString(meta.Key) + "\", Value = \"" + meta.Value.Replace("\"", "\\\"") + "\")]");
            }
and it works fine.
Just adding it here for codetools to add it to source code.
I would submit a patch myself but dont know how to use the source control stuff in codeplex.
Thanks
Giannis

comments