New Posts New Posts RSS Feed: Disable lazy loading for custom objects
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Disable lazy loading for custom objects

 Post Reply Post Reply
Author
GeertvanHorrik View Drop Down
Newbie
Newbie


Joined: 23-Jun-2011
Posts: 6
Post Options Post Options   Quote GeertvanHorrik Quote  Post ReplyReply Direct Link To This Post Topic: Disable lazy loading for custom objects
    Posted: 23-Jun-2011 at 7:48am
Hello,

I have a custom query where I want to load a simple structure:

Products and Orders. I have created POCO's for the objects since the EF model is too heavy for displaying some dashboard information.

Now I have 2 questions:

1) How can I disable lazy loading of the 2nd layer? An order contains a list of products, but the products are not loaded (even though it is a custom POCO class). How can I force DevForce to execute the whole linq query for this query only?

2) It seems impossible to subtract time in LINQ. Is there a workaround for this?

Thanks in advance!
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 23-Jun-2011 at 4:59pm
Hi GeertvanHorrik,
 
1) You can disable lazy loading by changing the LoadStrategy:
 
Order.PropertyMetadata.Products.ReferenceStrategy =
          new EntityReferenceStrategy(EntityReferenceLoadStrategy.Load, MergeStrategy.PreserveChanges);
 
You will find more details about the ReferenceStrategy in the DevForce Resource Center.
 
 
2) "It seems impossible to subtract time in LINQ. Is there a workaround for this?"
 
     I'm not sure I understand your question. Can you explain in detail what you are trying to do and what problem you are coming across?
 
Regards,
   Silvio.
Back to Top
GeertvanHorrik View Drop Down
Newbie
Newbie


Joined: 23-Jun-2011
Posts: 6
Post Options Post Options   Quote GeertvanHorrik Quote  Post ReplyReply Direct Link To This Post Posted: 25-Jul-2011 at 12:48am
Hello Silvio,

Sorry for my late reply. 

1) thanks

2) I tried to subtract a date in a query, but this seems to be an EF restriction
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down