NOODB: Query works!

I’m pretty pleased right now. I can now run queries in NOODB. Sure, they’re just simple queries, but everything starts with a first step.

            TestUtility.DeleteTestData();
            NoodbClient client = new NoodbClient(new Server(TestUtility.UnityContainer));
            client.RegisterType<QueryPerson>();

            client.Save(new QueryPerson { FirstName = "jay", LastName = "allard" });
            client.Save(new QueryPerson { FirstName = "gina", LastName = "allard" });
            client.Save(new QueryPerson { FirstName = "paul", LastName = "allard" });
            client.Save(new QueryPerson { FirstName = "jack", LastName = "allard" });
            client.Save(new QueryPerson { FirstName = "amy", LastName = "harrington" });
            client.Save(new QueryPerson { FirstName = "dawn", LastName = "almas" });

            Collection<QueryPerson> matches = client.Query<QueryPerson>("from p in QueryPerson where p.FirstName='amy' || p.LastName='almas'");
            var ordered = matches.OrderBy(match => match.FirstName).ToList();
            Assert.AreEqual(2, matches.Count);
            Assert.AreEqual("amy", ordered[0].FirstName);
            Assert.AreEqual("dawn", ordered[1].FirstName);

You can’t do joins or property drilling yet, but hey, let’s focus on what we can do. We can write queries!

I’m going to do some easy stuff for a while; add some more operators; maybe do an IN, stuff like that.

The query that I previously posted had to be changed slightly. As I wrote it, I was expecting there to be a pivot table available, but that ended up not being practical. So, the structure of the query is the same, but instead of saying LASTNAME=, it says VALUESTRING=, or VALUEINT=, etc.

This is what I’ve been working towards since day 1. This is a good day in the NOODB universe (population: 1).

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: