<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3395366571896245199</id><updated>2011-11-27T15:56:25.361-08:00</updated><category term='c#'/><category term='NHibernate'/><category term='Fluent NHibernate'/><category term='scrum noob'/><category term='.NET-4.0'/><category term='mapping'/><category term='SQLite'/><category term='nuget'/><category term='mspec'/><category term='rhino.security nhibernate sharp-architecture'/><title type='text'>Monkey With Tools</title><subtitle type='html'>This monkey now has a bone, and he is not afraid to use it.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://monkeywithtools.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3395366571896245199/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://monkeywithtools.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Kurt Johnson</name><uri>http://www.blogger.com/profile/17846505942158712743</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_Xp16MDX07s4/SrjuU9OsDLI/AAAAAAAAAJE/ST7JbC_3k1c/s1600-R/b95dd43854d7e3f9d7bc9bd75fbe1dd6%3Fs%3D80'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3395366571896245199.post-6004196889653074277</id><published>2011-06-08T16:21:00.000-07:00</published><updated>2011-06-08T18:49:39.835-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQLite'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET-4.0'/><category scheme='http://www.blogger.com/atom/ns#' term='mspec'/><category scheme='http://www.blogger.com/atom/ns#' term='nuget'/><category scheme='http://www.blogger.com/atom/ns#' term='NHibernate'/><title type='text'>Running Machine.Specifications console runner in mixed mode</title><content type='html'>&lt;p&gt;Our test project has just been upgraded to .NET 4.0. That caused some problems with the .NET 2.0 references, particularly SQLite. Here's the error you get right after a &lt;a href="http://www.nuget.org/"&gt;Nuget&lt;/a&gt; install:&lt;/p&gt;&lt;br /&gt;&lt;pre name="code" class="brush:html"&gt;NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. ---&amp;gt; System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&amp;gt; System.ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://stackoverflow.com/questions/4214700/could-not-create-the-driver-from-nhibernate-driver-sqlite20driver"&gt;This&lt;/a&gt; &lt;a href="http://stackoverflow.com/questions/2627145/problem-upgrading-nhibernate-sqlite-application-to-net-4-0"&gt;is&lt;/a&gt; &lt;a href="http://stackoverflow.com/questions/2649194/sqlite-nhibernate-configuration-with-net-4-0-and-vs-2010"&gt;a well-known issue&lt;/a&gt;. Basically, SQLite is a .NET 2.0 targeted app. I am working in .NET 4.0. I followed &lt;a href="http://gurustop.net/blog/2011/05/19/sqlite-database-nuget-package-common-problems-solved/"&gt;Mohamed Meligy's instructions&lt;/a&gt; and added some edits to my test assembly's configuration file (app.config).&lt;/p&gt;&lt;br /&gt;&lt;p&gt;ReSharper and MSPEC ran my specs just fine. So, I then ran my MSBUILD project. I have a target that runs the mspec.exe console runner. I get the HibernateException again.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;What gives?&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Well, it turns out that the executables that you &lt;i&gt;"nuget"&lt;/i&gt; from the package don't include configuration files. Sure, I had the edits for running mpsec from &lt;i&gt;within&lt;/i&gt; Visual Studio's IDE using ReSharper's TestRunner. But mspec.exe is its own AppDomain -- you still need those configuration edits there.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;To apply the configuration edits, you need a file. The nuget package didn't create them, so I did it manually.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;In my packages/Machine.Specifications.0.4.12/tools folder, I created an mspec.exe.config file, and one for each of the other exe's. Inside, I placed the startup node with the legacy redirect. Additionally, I added the system.data node. Now, each mspec executable will leverage the mixed-mode framework setup to make SQLite happy.&lt;/p&gt;&lt;br /&gt;Now, all tests pass just as they do in my test runner within my IDE.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3395366571896245199-6004196889653074277?l=monkeywithtools.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://monkeywithtools.blogspot.com/feeds/6004196889653074277/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://monkeywithtools.blogspot.com/2011/06/running-machinespecifications-console.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3395366571896245199/posts/default/6004196889653074277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3395366571896245199/posts/default/6004196889653074277'/><link rel='alternate' type='text/html' href='http://monkeywithtools.blogspot.com/2011/06/running-machinespecifications-console.html' title='Running Machine.Specifications console runner in mixed mode'/><author><name>Kurt Johnson</name><uri>http://www.blogger.com/profile/17846505942158712743</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_Xp16MDX07s4/SrjuU9OsDLI/AAAAAAAAAJE/ST7JbC_3k1c/s1600-R/b95dd43854d7e3f9d7bc9bd75fbe1dd6%3Fs%3D80'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3395366571896245199.post-9149686423558599751</id><published>2010-02-05T09:36:00.000-08:00</published><updated>2010-02-05T09:46:11.368-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rhino.security nhibernate sharp-architecture'/><title type='text'>Figuring out Rhino.Security and on-demand filtering</title><content type='html'>Ayende's &lt;a href="http://github.com/ayende/rhino-security"&gt;Rhino.Security&lt;/a&gt; is an enterprise authorization framework. I recently added it to my &lt;a href="http://www.sharparchitecture.net"&gt;Sharp Architecture&lt;/a&gt; project using &lt;a href="http://devlicio.us/blogs/billy_mccafferty/archive/2009/04/30/adding-rhino-security-support-to-s-arp-projects.aspx"&gt;Billy McCafferty's instructions&lt;/a&gt; and some help from Bart Reserhove's &lt;a href="http://bartreyserhove.blogspot.com/"&gt;blog&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The next step is a spike to implement Rhino.Security authorization and then determining the best course of intercepting queries with permissions. Also, I understand that I can use the event subsystem in NHibernate, instead of an interceptor. I have to check both out.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3395366571896245199-9149686423558599751?l=monkeywithtools.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://monkeywithtools.blogspot.com/feeds/9149686423558599751/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://monkeywithtools.blogspot.com/2010/02/querying-rhinosecurity.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3395366571896245199/posts/default/9149686423558599751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3395366571896245199/posts/default/9149686423558599751'/><link rel='alternate' type='text/html' href='http://monkeywithtools.blogspot.com/2010/02/querying-rhinosecurity.html' title='Figuring out Rhino.Security and on-demand filtering'/><author><name>Kurt Johnson</name><uri>http://www.blogger.com/profile/17846505942158712743</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_Xp16MDX07s4/SrjuU9OsDLI/AAAAAAAAAJE/ST7JbC_3k1c/s1600-R/b95dd43854d7e3f9d7bc9bd75fbe1dd6%3Fs%3D80'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3395366571896245199.post-8754517475266876479</id><published>2010-02-05T09:30:00.000-08:00</published><updated>2010-02-05T10:19:43.696-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scrum noob'/><title type='text'>Scrum: Now, bite sized!</title><content type='html'>Our small development team has been adopting Scrum using the Lightweight Scrum TFS template. &lt;br /&gt;&lt;br /&gt;Adopting. I should say "attempting to adopt".&lt;br /&gt;&lt;br /&gt;I have been researching the web for "freesources" on Scrum adoption, the lifecycle of a project, roles, user stories, implementation in a .NET shop, creating of executable specifications, etc. &lt;br /&gt;&lt;br /&gt;Wow. Scrum is all over the place -- as in, widespread adoption and many opinions on proper implementation.&lt;br /&gt;&lt;br /&gt;Our team is small -- two developers and a Scrum Master. Our initial sprint is for evaluation. We are tracking how to implement using a small bite-size project -- a simple display/edit screen. The user stories as of the moment don't even include authorization. We simply want to evaluate all of the scrum ceremonies and artifacts in action, in a short life-cycle.&lt;br /&gt;&lt;br /&gt;What's more, we are also implementing our project using domain-driven design. If that seems like a recipe for failure, I disagree. The luxury we have is low visibility and a small enough team that we can communicate well.&lt;br /&gt;&lt;br /&gt;Let's see how this goes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3395366571896245199-8754517475266876479?l=monkeywithtools.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://monkeywithtools.blogspot.com/feeds/8754517475266876479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://monkeywithtools.blogspot.com/2010/02/scrum-and-sharp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3395366571896245199/posts/default/8754517475266876479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3395366571896245199/posts/default/8754517475266876479'/><link rel='alternate' type='text/html' href='http://monkeywithtools.blogspot.com/2010/02/scrum-and-sharp.html' title='Scrum: Now, bite sized!'/><author><name>Kurt Johnson</name><uri>http://www.blogger.com/profile/17846505942158712743</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_Xp16MDX07s4/SrjuU9OsDLI/AAAAAAAAAJE/ST7JbC_3k1c/s1600-R/b95dd43854d7e3f9d7bc9bd75fbe1dd6%3Fs%3D80'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3395366571896245199.post-1618790205329251730</id><published>2009-06-18T07:04:00.001-07:00</published><updated>2010-10-07T08:39:12.506-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NHibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='mapping'/><category scheme='http://www.blogger.com/atom/ns#' term='Fluent NHibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><title type='text'>Mapping Method Properties with NHibernate, FNH</title><content type='html'>&lt;p&gt;I have an experimental project that will likely evolve later with &lt;span style="font-style: italic;"&gt;real&lt;/span&gt; specs and everything. With this greenfield of no intervention, I can spike away with NHibernate's hot-roddin' buddies: Fluent NHibernate and NHibernate.Linq.&lt;/p&gt;&lt;p&gt;Admittedly, I view NHibernate the way the monkey looked at the monolith in the movie &lt;b&gt;2001 : A Space Odyssey&lt;/b&gt; - a mixture of abject fear and wonderment. I have been flinging a lot of things at the "black-shiny" to no avail.&lt;/p&gt;&lt;p&gt;I want to implement the specifications pattern in Linq. The idea of having Linq  specifications is very compelling. So off I toddled with my new bones in hand, ready to fling them with impunity at the "black-shiny".&lt;/p&gt;&lt;p&gt;I have an abstract User with value objects for a Person and Address. For this post, I will focus on the Person value object that contains name properties for first and last name. My end-users will want to be able to filter the User entity on those that contain a name part in the full name - a concatenation of first and last name.&lt;/p&gt;&lt;p&gt;Here's my code so far:&lt;/p&gt;&lt;pre class="brush: csharp"&gt;public class User : AbstractUser{&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;public abstract AbstractUser&lt;br /&gt;{&lt;br /&gt;        public virtual Person Person {get; private set:}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;public class Person{&lt;br /&gt;        public virtual string LastName {get; private set;}&lt;br /&gt;        public virtual string FirstName {get; private set;}&lt;br /&gt;&lt;br /&gt;        public Person (string firstName, string lastName){&lt;br /&gt;                FirstName = firstName;&lt;br /&gt;                LastName = lastName;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public string FullName{&lt;br /&gt;                get{&lt;br /&gt;                        return string.Format("{0} {1}", FirstName, LastName);&lt;br /&gt;                }&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;OK, that's fine. Now, I need to map my User entity. Mapping is trivial using Standard Mapping in Fluent NHibernate. I will also include my Person value object as a convention, so I can re-use that again as needed.&lt;/p&gt;&lt;pre class="brush: csharp"&gt;public class UserMap : ClassMap&amp;lt;User&amp;gt;&lt;br /&gt;    {&lt;br /&gt;        public UserMap()&lt;br /&gt;        {&lt;br /&gt;            Id(x =&amp;gt; x.Id).GeneratedBy.Identity();&lt;br /&gt;            Component(x =&amp;gt;&lt;br /&gt;                    x.Person, PersonConvention.MapPerson(""));&lt;br /&gt;        }&lt;br /&gt;    } &lt;br /&gt;    public class PersonConvention&lt;br /&gt;    {&lt;br /&gt;        public static Action&amp;lt;ComponentPart&amp;lt;Person&amp;gt;&amp;gt; MapPerson(string columnPrefix)&lt;br /&gt;        {&lt;br /&gt;            return p =&amp;gt;&lt;br /&gt;                       {&lt;br /&gt;                           p.Map(n =&amp;gt; n.FirstName).WithLengthOf(50);&lt;br /&gt;                           p.Map(n =&amp;gt; n.LastName).WithLengthOf(50);&lt;br /&gt;                           p.Map(n =&amp;gt; n.MiddleInitial).WithLengthOf(1);&lt;br /&gt;                       };&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Looks good so far. Now, I am using NHibernate.Linq and Linq.Specifications. I might know a portion of Mr. Smith's name, but not how to spell it. I need to filter those Users by their full name with a Contains on the full name.&lt;br /&gt;&lt;/p&gt;&lt;pre class="brush: csharp"&gt;    public class UserNameSpecification : QuerySpecification&amp;lt;User&amp;gt;&lt;br /&gt;    {&lt;br /&gt;        private readonly string _name;&lt;br /&gt;&lt;br /&gt;        public UserNameSpecification(string namePart)&lt;br /&gt;        {&lt;br /&gt;            _name = namePart;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public override Expression&amp;lt;Func&amp;lt;User, bool&amp;gt;&amp;gt; MatchingCriteria&lt;br /&gt;        {&lt;br /&gt;            get { &lt;br /&gt;                return u =&amp;gt; u.Person.FullName.Contains(_name); &lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Now, I should be able to query for FullName, right? I mean: it's a method result of two properties, not a value. At least, that's what I thought at first.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;When Linq.NHibernate transmogrifies the C# into HQL, it has no idea how to translate FullName into its component FirstName, LastName.&lt;/p&gt;&lt;p&gt;Hmm, I must have missed a step somewhere. NHibernate.Linq has no idea about the contents of my MatchingCriteria() method. For all it knows, FullName is a string property.&lt;/p&gt;&lt;p&gt;Wait a second... My FullName() method might as well be a string property!&lt;/p&gt;&lt;p&gt;So if I map FullName() to Fluent NHibernate - Sure, it becomes a column. But, I can control the contents in my domain. I can now persist the method property to my persistence mechanism (DDD-speak for database, in this instance) and use it for querying later.&lt;/p&gt;&lt;p&gt;Here's the updated PersonConvention&lt;/p&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;    public class PersonConvention&lt;br /&gt;    {&lt;br /&gt;        public static Action&amp;lt;ComponentPart&amp;lt;Person&amp;gt;&amp;gt; MapPerson(string columnPrefix)&lt;br /&gt;        {&lt;br /&gt;            return p =&amp;gt;&lt;br /&gt;                       {&lt;br /&gt;                           p.Map(n =&amp;gt; n.FirstName).WithLengthOf(50);&lt;br /&gt;                           p.Map(n =&amp;gt; n.LastName).WithLengthOf(50);&lt;br /&gt;                           p.Map(n =&amp;gt; n.MiddleInitial).WithLengthOf(1);&lt;br /&gt;                           p.Map(n =&amp;gt; n.FullName).SetAttribute("access","readonly");&lt;br /&gt;                       };&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;In my Setup method, I have inserted a "first user". I have FullName marked with the readonly attribute. Now, I can use the FindAll and pass in my specification.&lt;/p&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;        [Test]&lt;br /&gt;        public void can_find_by_full_name()&lt;br /&gt;        {&lt;br /&gt;            IQueryable&amp;lt;User&amp;gt; byfullname = userRepository.FindAll(new UserNameSpecification("first user"));&lt;br /&gt;            Assert.AreEqual(1, byfullname.Count());&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;It passes. By the way, my repository's FindAll with the Linq.Specification implementation is as follows:&lt;/p&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;&lt;br /&gt;        public IQueryable&amp;lt;TResult&amp;gt; FindAll&amp;lt;TResult&amp;gt;(ISpecification&amp;lt;User, TResult&amp;gt; specification)&lt;br /&gt;        {&lt;br /&gt;            return specification.SatisfyingElementsFrom(FindAll());&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Keep in mind that this is not the end-game for NHibernate. AST to HQL parser projects appear to be in the works. Hopefully, we will be able to pass the contents of a method to NHibernate parse that to HQL for us. But until that is complete, we have the option of persisting method property results that NHibernate.Linq can parse.&lt;/p&gt;&lt;p&gt;Special thanks on the resolution of this issue goes to &lt;a href="http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/b0f26c57c7cf1eb2"&gt;Hudson Akridge&lt;/a&gt; for pointing me in the right direction. Also, I would be remiss if I did not extend thanks to &lt;a href="http://www.mostlyclean.com/post/2008/08/Linq-Expressions-The-Specification-Pattern-and-Repositories-Part-1.aspx"&gt;Steven Burman, the Mostly Clean Coder&lt;/a&gt;. Steven's posts on Linq.Specifications is an excellent resource for his project. He was also very kind to assist on a question I had. Thanks again, guys.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3395366571896245199-1618790205329251730?l=monkeywithtools.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://monkeywithtools.blogspot.com/feeds/1618790205329251730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://monkeywithtools.blogspot.com/2009/06/mapping-method-properties-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3395366571896245199/posts/default/1618790205329251730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3395366571896245199/posts/default/1618790205329251730'/><link rel='alternate' type='text/html' href='http://monkeywithtools.blogspot.com/2009/06/mapping-method-properties-with.html' title='Mapping Method Properties with NHibernate, FNH'/><author><name>Kurt Johnson</name><uri>http://www.blogger.com/profile/17846505942158712743</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_Xp16MDX07s4/SrjuU9OsDLI/AAAAAAAAAJE/ST7JbC_3k1c/s1600-R/b95dd43854d7e3f9d7bc9bd75fbe1dd6%3Fs%3D80'/></author><thr:total>0</thr:total></entry></feed>
