DataMember attribute with order and EmitDefaultValue in EF6 template

Posts   
 
    
pat
User
Posts: 215
Joined: 02-Mar-2006
# Posted on: 25-Apr-2017 05:53:13   

Could you please explain how I can output this attribute: [DataMember(Order = 3, EmitDefaultValue = false)] public string ProviderIdentifier { get; set; }

instead of this one: [DataMember(Order)] public string ProviderIdentifier { get; set; }

Ideally this would be something which can be adjusted per field

Thanks! Patrick


EF6 template

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Apr-2017 07:30:30   

Hi Patrick,

There is no built-in support for what you want. However there are some options. Please read this thread: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=24097

In the last post there's a suggestion for a Plugin. Hope that helps.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39612
Joined: 17-Aug-2003
# Posted on: 25-Apr-2017 09:26:51   

Could you elaborate a bit why you'd need the Order value in the attribute? Is it for serialization purposes? (this to give us a picture about how to prioritize adding the macro. I assume this is for attributes on the entity field) Thanks.

(to elaborate why it isn't there: fields in an entity have by definition no 'order': they're sorted alphabetically. You can give them an order (see: http://www.llblgen.com/Documentation/5.1/Designer/Functionality%20Reference/FieldOrdering.htm), but in EF this is ignored mainly, because EF doesn't care about field ordering. As field ordering based on an index isn't used by default (and in most cases, it's unnecessary), there's no macro for the attribute definitions for field index.)

Frans Bouma | Lead developer LLBLGen Pro
pat
User
Posts: 215
Joined: 02-Mar-2006
# Posted on: 26-Apr-2017 08:12:48   

Let me get back to you why we are thinking that we need the ordering after I consulted what has been written in the link above.

But is there support for adding this to the attribute? EmitDefaultValue = false

Thanks! Patrick

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39612
Joined: 17-Aug-2003
# Posted on: 26-Apr-2017 10:32:33   

pat wrote:

Let me get back to you why we are thinking that we need the ordering after I consulted what has been written in the link above.

But is there support for adding this to the attribute? EmitDefaultValue = false

Thanks! Patrick

Yes. You can apply attributes manually in the Code generation info tab or (preferably) do this by specifying rules for attribute definitions, so the designer will apply them on the fields / entities matching the rules. Please see: http://www.llblgen.com/Documentation/5.1/Designer/How%20To/AssignAttributesToElements.htm

Frans Bouma | Lead developer LLBLGen Pro