Microsoft Helping to Launch National Day of GiveCamp

It is very exciting to see that Microsoft is stepping it up when it comes to helping developers give back to the community. 

Scheduled for January 14-16, 2011, to coincide with the MLK National Holiday, the National Day of GiveCamp will be a single day where GiveCamp events will be run simultaneously in multiple cities all over the US.

This is a cause that is very close to my heart and I have been working very hard to help bring the GiveCamp event to Northwest Arkansas.

It is also very exciting to see that many of these events will be using the Give Camp Starter Site.  This open source project hosted on codeplex has become a focus on mine in the recent months.

I look forward to seeing all the good that can happen on a single weekend and hope to get lots of feedback on what we can do in the next release of the starter site.

For those of you looking for assistance on getting the starter site up and running don’t hesitate to contact me.  I will also be posting some more detailed blogs about how to do common things in the starter site to allow you to customize it to your needs.

Press Release: First Northwest Arkansas GiveCamp Announced!

NwaGiveCampLogo

Northwest Arkansas GiveCamp Brings Free Technology Solutions to Non-Profits during Weekend Event

August 22, 2010 -- Fayetteville, AR – Jay Smith, Northwest Arkansas GiveCamp Chairman, announced today that the Northwest Arkansas .Net user Group in Partnership with the University of Arkansas will be hosting the first annual Northwest Arkansas GiveCamp on January 14-16, 2011.

The Northwest Arkansas GiveCamp is a weekend-long event that brings together local technology professionals to providing non-profits with technical solutions and applications they might not otherwise been able to afford.

The Northwest Arkansas GiveCamp is one of many events of this type that are happening all over the country. This unique event allows technology professionals to use the skills they develop every day to provide applications and services that are in need by non-profits.

The Northwest Arkansas GiveCamp will be held in the University of Arkansas Union Ballroom and surrounding meeting rooms.

Charities and Non-Profits requesting help and volunteers willing to offer their time and skills can submit their application on-line at Northwest Arkansas GiveCamp website located at http://nwagivecamp.com.

The press is invited to the event opening to be held on January 14, 2011 at 00 PM where the selected non-profits will introduce themselves and meet their development teams for the first time.

The press is also invited to the event closing where teams will be giving a brief presentation showing the work they have accomplished for each non-profit.

Summary:

Date: January 14-16, 2011
Location: University of Arkansas Union Ballroom

About the Northwest Arkansas .Net User Group
The Northwest Arkansas .NET User Group is a 501(c)(3) non-profit organization that is dedicated to the promotion, education and adoption of Microsoft .NET Technologies. We strive to provide an environment for professionals to network in Northwest Arkansas to foster the free exchange of ideas and information.

 

GiveCamp_480x60_green

Speaking at Houston TechFest on October 9th, 2010

HoustonTechFest2010Logo

I have confirmed I will be attending and speaking that the Houston TechFest 2010 on October 9th, 2010.  I will be presenting my Planning Poker session, recording interviews for User Group Radio and of course talking community any chance I get.

I am also working with Zain Naboulsi about organizing a Community Leadership Town Hall Meeting the night before the conference.  This will be a dinner with an open space/fish bowl style discussion on creating, building, and sustaining community.

Looks like the Houston TechFest site hasn’t bee updated yet so here is the info on my session:

Estimate Your Requirements with Planning Poker

Planning Poker is a consensus-based estimation technique for estimating, mostly used to estimate effort or relative size of tasks in software development . It is a variation of the Wideband Delphi method. In this session you will learn not only what planning poker is but how to facilitate it with your team. Using Planning Poker to estimate task on your project is not only accurate its fun.

Generic Repository for Entity Framework

*UPDATED 9/6/2012*
Thanks to Stephen Dooley for bringing to my attention that Mikael’s post is no longer available.  I have updated the post to include the extension methods that he had originally posted.  You can find them at the end of the post.
*End Update*

I have started trying to learn how to leverage the Entity Framework for a the re-write of the GiveCamp Starter Site and wanted to implement a generic repository for data access like I use on most of my projects.  I started with the example given by Mikael Henriksson’s Post Generic Repository for Entity Framework for Pluralized Entity Set.  I modified it to fit my standard Repository interface and took the liberty of simplifying it in a few places.

I have run this through several test and haven’t found any issues. I would love those with a critical eye to give this a look over and let me know if I am missing anything.

The IRepository Interface

 1: public interface IRepository : IDisposable
 2:    {
 3:      T Get<T>(int id) where T : IEntityWithKey;
 4:      T Get<T>(Expression<Func<T, bool>> predicate) where T : IEntityWithKey;
 5:        IQueryable<T> Find<T>(Expression<Func<T, bool>> predicate) where T : IEntityWithKey; 
 6:      T Save<T>(T entity) where T : IEntityWithKey;
 7:      T Delete<T>(T entity) where T : IEntityWithKey;
 8:    }

I did use the ObjectContextExtensions from Mikael’s post because they did such a good job of solving the issue of getting the EntitySetName. I am not going go into a lot of detail explaining what is going on because a feel the class pretty much explains itself.

The Repository Class:

 1: public class EntityFrameworkRepository : IRepository   
 2: {
 3:     private readonly ObjectContext context;
 4:     public EntityFrameworkRepository()
 5:     {
 6:         context = new WmdDemoEntities();
 7:     }
 8:      
 9:     public EntityFrameworkRepository(ObjectContext entityContext)
 10:     {
 11:         context = entityContext;
 12:     }
 13:     
 14:     public T Get<T>(int id) where T : IEntityWithKey
 15:     {
 16:         IEnumerable<KeyValuePair<string, object>> entityKeyValues = new[] { new KeyValuePair<string, object>("Id", id) };
 17:         var key = new EntityKey(context.GetEntitySet<T>().Name, entityKeyValues);
 18:         return (T)context.GetObjectByKey(key);
 19:     }
 20:     
 21:     public T Get<T>(Expression<Func<T, bool>> predicate) where T : IEntityWithKey
 22:     {
 23:         return context.CreateQuery<T>("[" + context.GetEntitySet<T>().Name + "]")
 24:         .Where(predicate)
 25:         .FirstOrDefault();
 26:     }
 27:     
 28:     public IQueryable<T> Find<T>(Expression<Func<T, bool>> predicate) where T : IEntityWithKey
 29:     {
 30:         return context
 31:         .CreateQuery<T>("[" + context.GetEntitySet<T>().Name + "]")
 32:         .Where(predicate);
 33:     }
 34:      
 35:     public T Save<T>(T entity) where T : IEntityWithKey
 36:     {
 37:         object originalItem;
 38:            if (context.TryGetObjectByKey(entity.EntityKey, out originalItem))
 39:             context.ApplyPropertyChanges(entity.EntityKey.EntitySetName, entity); 
 40:         else
 41:             context.AddObject(entity.EntityKey.EntitySetName, entity);
 42:        
 43:        context.SaveChanges();
 44:        return entity;
 45:     }
 46:     
 47:     public T Delete<T>(T entity) where T : IEntityWithKey
 48:     {
 49:         context.DeleteObject(entity);
 50:         context.SaveChanges();
 51:         return entity;
 52:     }
 53:     
 54:     public void Dispose()
 55:     {
 56:         context.Dispose();
 57:     }
 58:  }
 

Here is an example of usage in a console application

 1: class Program
 2:  {
 3:    static void Main(string[] args)
 4:    {
 5:      IRepository repository = new EntityFrameworkRepository();
 6:        var page = repository.Get<Page>(x => x.PageId == 1);
 7:        Console.WriteLine("Title: {0}", page.Title);
 8:      Console.WriteLine("Content: {0}", page.Content);
 9:        repository.Dispose();
 10:        Console.ReadLine();
 11:    }
 12:  }

I love taking this approach to persistence because it is so flexible and allows me to swap out repository implementations with little issue.

Again love to hear some feedback on this approach.

Mikael Henriksson’s Original Extension Methods

 1: using System.Data.Metadata.Edm;
 2: using System.Data.Objects;
 3: using System.Data.Objects.DataClasses;
 4:  
 5: public static class ObjectContextExtensions
 6: {
 7:     internal static EntitySetBase GetEntitySet<TEntity>(this ObjectContext context)
 8:     {
 9:         EntityContainer container = context.MetadataWorkspace
 10:                                                         .GetEntityContainer(context.DefaultContainerName, DataSpace.CSpace);
 11:         Type baseType = GetBaseType(typeof(TEntity));
 12:         EntitySetBase entitySet = container.BaseEntitySets
 13:                                                     .Where(item => item.ElementType.Name.Equals(baseType.Name))
 14:                                                     .FirstOrDefault();
 15:  
 16:         return entitySet;
 17:     }
 18:  
 19:     private static Type GetBaseType(Type type)
 20:     {
 21:             var baseType = type.BaseType;
 22:             if (baseType != null && baseType != typeof(EntityObject))
 23:             {
 24:                 return GetBaseType(type.BaseType);
 25:             }
 26:             return type;
 27:     }
 28: }

GiveCamp Starter Site v1.2 Alpha Released

GiveCampStartSite

I am happy to announce the alpha release of the GiveCamp Starter Site.  This release is a minor feature release that contains additional fields for volunteer registration to capture Shirt Size and Shirt Style, as well as, a new default theme.

With this release I am also trying to beef up the documentation.  Please download and test this version and look over the new documentation and give me your feedback. 

The new documentation is not complete but the rough outline is there.  If you are interested in joining the team to help with documentation please let me know.

Calendar

<<  March 2024  >>
MonTueWedThuFriSatSun
26272829123
45678910
11121314151617
18192021222324
25262728293031
1234567

View posts in large calendar

Widget Category list not found.

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))X

Tag cloud

    Widget Month List not found.

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))X

    Widget AuthorList not found.

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))X

    Widget TextBox not found.

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))X