Monday, August 17, 2009

Creating “In” or “Exists” clauses in EntityFramework

To create the equivalent of a SQL “Exists” clause in EntityFramework, do the following:

ddlRecipe.DataSource = from r in _global.db.Recipe
              where (from    u in _global.db.RecipeUser
                     where u.UserId == _global.CurrentUser.Id
                        && u.RecipeId == r.ID
                     select u.RecipeId).Any()
                || (r.HTIRecipe && _global.CurrentUser.HTIEmployee)
                orderby r.Name
              select new { r.ID, r.Name };

In this case the query is returning all Recipes where there exists a RecipeUser in the other collection.

Monday, August 3, 2009

Installing new modules in DNN

To install the feedback module in DotNetNuke, I had to go into permissions and grant full control to ‘Everyone’ to get it to install successfully.  After the install, I removed the permissions again.  Not sure why, but nothing else worked.  Without doing this it kept complaining about File access permissions to \bin\DotNetNuke.Modules.Feedback.dll.