This project is read-only.

Demo not saving data, confusion over domain save

Oct 18, 2010 at 9:51 AM

Hello, I'm running the demo and everything seems to work but I'm not seeing any read data. So when I add a new recipe everything seems to run fine and the TheKitchenEvents table is populated however there is nothing in the Recipes table. So looking at the architecture diagram I thought the domain repository was saving the data to the underlying table and publishing the events. Have I got this wrong? Is the domain only saving the events and then something is supposed to pick the events up and save to the corresponding underlying readdata table?

 

Coordinator
Oct 19, 2010 at 6:35 AM

No, but are you running the self-hosted NServiceBus through the Querying.Core project? That's the receiving side that will write the events to the read store.

Oct 19, 2010 at 6:56 AM

I'm guessing not, I've just run through NCQRS' demo so I can see it's relying on eventing and denormalizing the data from the event data.  So I must, as you suggest, be having teething trouble with NServiceBus. Thanks again for the reply.

Coordinator
Oct 19, 2010 at 6:59 AM

Make sure you run the application as is explained in the Instructions section of this site's home page.

Oct 19, 2010 at 10:22 AM

Ok I'm slowly getting there. The problem was that I'd set the project to use NServicebus.exe in the tools folder rather than the one in the projects output folder. So it now consumes the events and creates data rows. However...I now have a problem with the query service to retrieve that data. If I ask for all recipes then it works fine, so the basic coms is ok. However, if I try to filter it fails. Perhaps I've not configured the Data Services properly? If I run the "REST" query by hand then I get;

ServiceRequest = {http://localhost:9003/QueryService.svc/Recipes()?$filter=substringof('z',Name)}

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>

- <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code />
  <message xml:lang="en-GB">Not Implemented</message>
  </error>

 

Oct 19, 2010 at 10:31 AM

Argh, looks like a Linq to NHibernate problem;

  <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
- <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code />
  <message xml:lang="en-GB">Not Implemented</message>
- <innererror>
  <message>The method Contains is not implemented.</message>
  <type>System.NotImplementedException</type>
  <stacktrace>at NHibernate.Linq.Visitors.RootVisitor.VisitMethodCall(MethodCallExpression expr) at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.BinaryCriterionVisitor.VisitMethodCall(MethodCallExpression expr) at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.BinaryCriterionVisitor.VisitUnary(UnaryExpression expr) at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.ExpressionVisitor.VisitConditional(ConditionalExpression c) at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.BinaryCriterionVisitor.GetBinaryCriteria(ICriteria rootCriteria, ISession session, BinaryExpression expr, ComparePropToValue comparePropToValue, ComparePropToProp comparePropToProp, CompareValueToCriteria compareValueToCriteria, ComparePropToCriteria comparePropToCriteria) at NHibernate.Linq.Visitors.WhereArgumentsVisitor.VisitBinaryCriterionExpression(BinaryExpression expr) at NHibernate.Linq.Visitors.WhereArgumentsVisitor.VisitBinary(BinaryExpression expr) at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.ExpressionVisitor.VisitConditional(ConditionalExpression c) at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.ExpressionVisitor.VisitLambda(LambdaExpression lambda) at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.WhereArgumentsVisitor.VisitUnary(UnaryExpression expr) at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.WhereArgumentsVisitor.GetCriterion(ICriteria rootCriteria, ISession session, Expression expression) at NHibernate.Linq.Visitors.RootVisitor.HandleWhereCall(MethodCallExpression call) at NHibernate.Linq.Visitors.RootVisitor.VisitMethodCall(MethodCallExpression expr) at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp) at NHibernate.Linq.Visitors.NHibernateQueryTranslator.TranslateInternal(Expression expression) at NHibernate.Linq.Visitors.NHibernateQueryTranslator.Translate(Expression expression, QueryOptions queryOptions) at NHibernate.Linq.NHibernateQueryProvider.TranslateExpression(Expression expression) at NHibernate.Linq.NHibernateQueryProvider.Execute(Expression expression) at NHibernate.Linq.Query`1.System.Collections.IEnumerable.GetEnumerator() at System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)</stacktrace>
  </innererror>
  </error>
Oct 19, 2010 at 11:07 AM

Hmm. I've hardcoded the QueryContext to always do a Contains to avoid the DataService adding that to query and that works ok;

public IQueryable<Recipe> Recipes
        {
            get {
                return Session.Linq<Recipe>().Where(r => r.Name.Contains("some"));
            }
        }
So it seems to be something about Data Services adding to the where clauses (??).
Coordinator
Oct 19, 2010 at 1:48 PM

I am ashamed of myself. Apparently, I never tested filtering recipes by name, or, it must have been a while back.

Oct 20, 2010 at 6:56 AM
Just had a quick tweet chat with the author and I'm going to have a look to see if I can fix Data Service linq2nh provider
Coordinator
Oct 27, 2010 at 8:16 PM

Yesterday I switched to NHibernate 3.0.0 Beta 1, but it is not yet working. Trying to figure out what's going on.

Coordinator
Nov 3, 2010 at 8:35 PM

I change the searching logic to use a WCF Data Service Service Operation and now it works.