Jeff-Lewis / codesmith

Automatically exported from code.google.com/p/codesmith
0 stars 0 forks source link

PLINQO: *Specified properties on EntityRefs and EntitySets #139

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We are using PLINQO in a project using classic Web Services in stead of
WCF. This means that EntityRefs/EntitySets cause circular reference exceptions.

The workaround was to use the well-hidden feature of the XmlSerializer
which makes it skip serializing property MyProperty if there is a property
called MyPropertySpecified set to false. I changed the templates to
accommodate for this, but it would be a nice addition to the standard
templates. We default to EntityRefs having Specified to true, and
EntitySets false. This can either be overriden in the OnCreated() partial
or at runtime before serializing.

EntityRef:

         private System.Data.Linq.EntityRef<<%= a.Type %>> <%= a.Storage %>;
+        private bool <%= a.Storage %>Specified = true;

+        public bool <%= a.Member %>Specified
+        {
+           get { return <%= a.Storage %>Specified; }
+           set { <%= a.Storage %>Specified = value; }
+       }

EntitySet:

         private System.Data.Linq.EntitySet<<%= a.Type %>> <%= a.Storage %>;
+        private bool <%= a.Storage %>Specified = false;

+        public bool <%= a.Member %>Specified
+        {
+           get { return <%= a.Storage %>Specified; }
+           set { <%= a.Storage %>Specified = value; }
+       }

Original issue reported on code.google.com by dasj...@gmail.com on 14 Sep 2009 at 9:32

GoogleCodeExporter commented 9 years ago
This seems like a good idea.  I can even improve on your idea by using the
HasLoadedOrAssignedValues property.  This way, it will automatically serialize 
only
the loaded relationships.

    private System.Data.Linq.EntitySet<<%= a.Type %>> <%= a.Storage %>;

+   public bool ShouldSerialize<%= a.Member %>()
+    {
+        return _<%= a.Storage %>.HasLoadedOrAssignedValues;
+    }

I'll update the templates.  I wonder if this should be a property on the 
template to
include Xml serialization?

Original comment by paul.wel...@gmail.com on 14 Sep 2009 at 1:54

GoogleCodeExporter commented 9 years ago

Original comment by shannon....@gmail.com on 18 Sep 2009 at 4:35

GoogleCodeExporter commented 9 years ago
Your improvement is a very cool idea, but will it work like that?

If we fetch an OrderLine, and use a LoadWith<OrderLine>(x => x.Order), we will 
get 
the following scenario:

orderLine.OrderSpecified: True
orderLine.Order.OrdersSpecified: True

This means we get a circular reference error when serializing. Only one of 
those 
should be true, and it seems difficult to automagically know which of them?

Original comment by dasj...@gmail.com on 28 Sep 2009 at 9:09

GoogleCodeExporter commented 9 years ago
I am using a standard web service as well... and getting a Circular reference 
still 
when using DataLoadOptions... I am using r985 and have IncludeXmlSerialization 
set 
to true... I tried it set to false as well, same problem...

Any progress on this?

Original comment by t...@troyzarger.com on 6 Oct 2009 at 12:44

GoogleCodeExporter commented 9 years ago

Original comment by shannon....@gmail.com on 6 Oct 2009 at 3:59

GoogleCodeExporter commented 9 years ago
Issue 154 has been merged into this issue.

Original comment by shannon....@gmail.com on 6 Oct 2009 at 3:59

GoogleCodeExporter commented 9 years ago
Hello,

Are you able to reproduce this with PLINQO 4.0.1?

Thanks
-Blake

Original comment by bniemyjski on 23 Dec 2009 at 1:27

GoogleCodeExporter commented 9 years ago
I have since changed all my code to not encounter this, but when I just now 
tested, 
it seems to go into an infinite loop now.

The schema is a self-referential PK/FK ... Such as:

MyTable
ID int
MyParentID int

You have a FK MyTable.MyParentID to PK MyTable.ID .... and you have two 
entries, the 
root and then a child pointing to the root via the MyParentID column... that is 
when 
it seems to go into an infinite loop.

Can you reproduce this?

Original comment by t...@troyzarger.com on 23 Dec 2009 at 3:46

GoogleCodeExporter commented 9 years ago
This still doesn't work (see comment 3). Please change it to my original 
suggestion, or at least make that an optional way of doing it.

Original comment by dasj...@gmail.com on 21 Jul 2011 at 7:25

GoogleCodeExporter commented 9 years ago
Hello,

Did it work in a previous version after we had made this change? Can you please 
expand on how it currently doesn't work (since we haven't gotten a comment on 
this in quite sometime).

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 25 Jul 2011 at 6:16

GoogleCodeExporter commented 9 years ago
No, it never worked, thus comment #3.

Original comment by dasj...@gmail.com on 25 Jul 2011 at 7:31

GoogleCodeExporter commented 9 years ago
Thanks, I'll bring this up to the development team during our next feedback 
meeting and see what we can do for this in the next PLINQO release.

Original comment by bniemyjski on 25 Jul 2011 at 7:39

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 25 Jul 2011 at 7:39