The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Non Nullbale column still gets a Nullable Property

Last post 08-11-2008, 2:39 PM by robert.wachtel. 17 replies.
Page 2 of 2 (18 items)   < Previous 1 2
Sort Posts: Previous Next
  •  08-11-2008, 8:14 AM 10681 in reply to 10680

    Re: Non Nullbale column still gets a Nullable Property

    Thanks Martin and Mike,

    I use MyGen - any help appreciated. Wink


    Greetings from Cologne

    Robert

    http://blog.robertsoft.de/
  •  08-11-2008, 10:51 AM 10684 in reply to 10681

    Re: Non Nullbale column still gets a Nullable Property

    Hi

    Ok - here's the part you need to change (but bear in mind this obviously isn't an official fix as you wouldn't normally want to alter any of the "Generated" templates as these change when new releases come out etc.

    Steps to follow:

    1) Open up MyGen

    2) Select the "EntitySpaces - ProxyStub (C#)" template from the Template Browser - it will be under the C#, Generated folder.

    3) Make sure the selected tab is "Template Code"

    4) Look for the following code "<% foreach(EntitySpaces.MetadataEngine.IColumn col in cols)"

    5) Select all code between that line (above) and the setter code line (shown here for reference): "set { this.Entity.<%=esMeta.esPlugIn.PropertyName(col)%> = value; }"

    6) replace all of the selected code with this:

    Code:
    <% foreach(EntitySpaces.MetadataEngine.IColumn col in cols)
     {
      lastOrdinal = col.Ordinal; %>
            <%if(WcfSupport){%>[DataMember(<%if(WcfOrder){%>Order=<%=col.Ordinal.ToString()%><%} if(WcfEmitDefaultValue){%>, EmitDefaultValue=false<%} if(WcfIsRequired && !col.IsNullable) {%>, IsRequired=true<%}%>)]<%}%>
            public <%=esMeta.esPlugIn.NullableType(col)%> <%=esMeta.esPlugIn.PropertyName(col)%>
            { 
                get 
                { 
                    <%if(col.IsInPrimaryKey || IsConcurrency(props, col)) { %>if (this.Entity.es.IsDeleted)
         return (<%=esMeta.esPlugIn.NullableType(col)%>)this.Entity.
          GetOriginalColumnValue(<%=esMeta.esPlugIn.Metadata(source)%>.ColumnNames.<%=esMeta.esPlugIn.PropertyName(col)%>);
                    else
                        return this.Entity.<%=esMeta.esPlugIn.PropertyName(col)%>;<% } else { %>
                   <%if(esMeta.esPlugIn.UseNullableTypesAlways) {%> if (this.IncludeColumn(<%=esMeta.esPlugIn.Metadata(source)%>.ColumnNames.<%=esMeta.esPlugIn.PropertyName(col)%>))
                        return this.Entity.<%=esMeta.esPlugIn.PropertyName(col)%>;
                    else
                        return null;<%}
         else {%> return this.Entity.<%=esMeta.esPlugIn.PropertyName(col)%>;<%}}%>
                }
                set { this.Entity.<%=esMeta.esPlugIn.PropertyName(col)%> = value; }

    That should do it - remember though that this isn't an EntitySpaces "fix" - just one user helping another Big Smile

    Cheers

    Martin

  •  08-11-2008, 2:39 PM 10693 in reply to 10684

    Re: Non Nullbale column still gets a Nullable Property

    Yes Great, thanks! Big Smile
    Greetings from Cologne

    Robert

    http://blog.robertsoft.de/
Page 2 of 2 (18 items)   < Previous 1 2
View as RSS news feed in XML