Page 1 of 1

Adding protobuf serialization to generated classes

Posted: Mon 11 Feb 2013 11:01
by SkeLLLa
Hello. I'm using Entity developer with postgres and I need to replace standart serialization for generated classes with protbuf serialization. So I need something like this:

Code: Select all

 [Serializable]
 [ProtoContract]
 public partial class MyClass : EntityObject
 {
  [ProtoMember(1)]
  public string Attribute1 { get {...}, set{...}}
  [ProtoMember(2)]
  public string Attribute2 { get {...}, set{...}}
  ...
 }
What I need to change in template to get such output?

Re: Adding protobuf serialization to generated classes

Posted: Wed 13 Feb 2013 10:52
by Shalex
There are two alternative ways:
1. Add the reference to the assembly with the protbuf serialization attributes via Model > Settings > Model > Attributes. After this, add the needed attributes to the model and its separate classes.
2. Right click on the template in Model Explorer > Copy to Model Folder. Modify the template to generate the protbuf serialization attributes in the code.

Re: Adding protobuf serialization to generated classes

Posted: Thu 14 Feb 2013 12:31
by SkeLLLa
Yes. Thanks. I've already modified template and generated proper classes. Also I've added

Code: Select all

[ProtoContract(UseProtoMembersOnly=true)]
to avoid serialization of reverences (Navigation properties)