Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Patterns, Principles and Practices of Domain-Driven Design
This is the forum to discuss the Wrox book Patterns, Principles and Practices of Domain-Driven Design by Scott Millett; ISBN: 978-1-118-71470-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Patterns, Principles and Practices of Domain-Driven Design section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 5th, 2015, 11:44 AM
Registered User
Points: 17, Level: 1
Points: 17, Level: 1 Points: 17, Level: 1 Points: 17, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2015
Posts: 4
Thanks: 2
Thanked 0 Times in 0 Posts
Default EF Repository

Hi,

I have a few questions regarding chapter 21, Entity Framework repository example:
- The EF example has additional data model and snapshot dto as compared to NHibernate example, is that because it's not possible to configure EF to map private properties of domain entities?

- Is snapshot dto sufficient in this case? .i.e. The EF mapping is configured to use snapshot instead of data model. I feel there are too many mapping (domain model -> snapshot -> data model) in the example.

- The EF repositories have Save() method, but as I know, EF does track changes of entities once it loads entities into memory. So is Save() method redundant?

Many thanks
Reply With Quote
  #2 (permalink)  
Old July 15th, 2015, 03:49 AM
Wrox Author
Points: 237, Level: 4
Points: 237, Level: 4 Points: 237, Level: 4 Points: 237, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2015
Posts: 59
Thanks: 1
Thanked 5 Times in 5 Posts
Default

Hey,

We haven't forgotten about this question. Scott is the EF man and he'll answer when he's back online.

Apologies for the delay.
Reply With Quote
  #3 (permalink)  
Old August 26th, 2015, 03:26 AM
Registered User
Points: 19, Level: 1
Points: 19, Level: 1 Points: 19, Level: 1 Points: 19, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2015
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think the point of creating the snapshot of the domain entities/value objects is so that the domain model and data model do not bleed into each other, which is what is bound to happen if you simply use the snapshot as your DTO. The memento pattern on display in this example is the solution to that problem.

I think the dynamic change tracking in EF makes extra requirements on the entity classes you use (all setters/getters must be declared virtual, etc.). I don't think that's being done here.

In fact, to get this example to work, I had to add a SaveChanges() call to the end of the BidHistoryRepository's Add method in order to get the bids saved to the BidHistory table. So, at the end of the IBidHistoryRepository.Add() method, I have this:

// Original last line of the method
_auctionExampleContext.Bids.Add(BidDTO);

// Added line to save the BidDTO to the database
_auctionExampleContext.SaveChanges();

This got the EF example working like the others.

Thank you very much,

Andy
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Repository in Domain varghesep BOOK: Patterns, Principles and Practices of Domain-Driven Design 2 July 4th, 2015 08:17 AM
Scafolding for non-EF? RKevinBurton BOOK: Professional ASP.NET MVC 4 0 March 24th, 2015 09:21 AM
connectionString using EF nanonerd ASP.NET 4 General Discussion 6 July 19th, 2012 01:28 PM
SVN Repository Hannes BOOK: Professional Joomla! ISBN: 978-0-470-13394-1 2 August 30th, 2010 05:17 AM



All times are GMT -4. The time now is 02:10 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.