Note that there are some explanatory texts on larger screens.

plurals
  1. POHighly Maintainable Web Services and adding new Command/Query handlers
    primarykey
    data
    text
    <p>I have started with <a href="http://solidservices.codeplex.com/" rel="nofollow noreferrer">this project</a> in an attempt to learn CQRS and write maintainable WCF services. However, I have some general questions on WCF. Every time I add a command/query handler contract and handler, I build the projects and then right click the service reference on the client in Visual Studio and choose "Update Service Reference". This usually allows me to work with the new command/query with no issues. </p> <p>However, more often than I would like, I have to actually delete the entire service reference and then add it back. That is the only way I can get around this error: </p> <blockquote> <p>There was an error while trying to serialize parameter <a href="http://tempuri.org/:query" rel="nofollow noreferrer">http://tempuri.org/:query</a>. The InnerException message was 'Type 'Contract.Queries.Countries.GetCountriesStartingWithLetterQuery' with data contract name 'GetCountriesStartingWithLetterQuery:<a href="http://schemas.datacontract.org/2004/07/Contract.Queries.Countries" rel="nofollow noreferrer">http://schemas.datacontract.org/2004/07/Contract.Queries.Countries</a>' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details.</p> </blockquote> <p>Then sometimes, I can NEVER get the new command/query to work even if I delete the service reference and re-add it. If I try to add a breakpoint in the WCF service code where the known types are being registered, it never gets hit. It seems the service reference is failing because the new command/query is not registered as a known type. </p> <p>What is the proper way to refresh a service in this CQRS WCF model? Thanks.</p> <hr> <p>Update 1: all of my trouble comes from EF generating proxy objects and trying to send them through the WCF service. The service doesn't know about proxies, just the POCOs. </p> <p>@Peter - I'm using EF 5 Code First. I have all of my POCOs in a separate project. I use the repository pattern to retrieve an entity from the database. When I say countryRepository.GetById(myId), a proxy object is retrieved, not a POCO. If I disable ProxyCreation, a POCO is returned but the navigation properties are always null while their respective foreign key ids are populated. Maybe I just need to use .Include for the nav properties when getting something out of the repository? I will have to check tomorrow since I don't have access to the code right now. </p> <p>Alternatively, I've read a lot about AutoMapper. Could that be used to map my proxy objects to POCOs? Just an idea but that doesn't seem correct. </p> <hr> <p>Edit 2: Turns out I can use ValueInjector to map my dynamic proxy objects to POCOs very easily. I can then send the POCOs over the wire with no issues. <a href="https://stackoverflow.com/questions/14708997/how-to-get-ef-pocos-from-system-data-entities-dynamicproxies">See this post</a> for further reference.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload