Entity Framework makes it very easy to get data from your database through mapped entities and having foreign keys mapped as navigation properties makes it really easy to traverse relationships in your database.  However, there is often a lot of overhead if you "include" your entire child entity along with the primary, parent entity.

For example, let's say we have an Order entity and each Order has a non-null ShippingAddressId that gives us a 1..1 to the Address entity.  We can use Include() to return that related Address entity:

public void IQueryable<Order> GetOrders(
{
    return this.ObjectContext.Orders.Include("Address");...
If you are like any other coder, cutting and pasting snippets should put up a red flag in your mind. You will quickly hit this threshold when creating CRUD-services for MVC 4 applications over and over again. This lead me to create a repository pattern using generic types and base controller classes that I would like to share with you. In the end, below is how my Web API classes look like, which automatically give me create, retrieve, update, and delete functionality:

using MvcWebApp.Helpers;
using MvcWebApp.Models.Data;
  
namespace MvcWebApp.Api
{
    public class SpeakersController : BaseApiController<Speaker>
    {
        //THIS ...
Every year, October kicks off a very busy season at Falafel : “Conference Season”. Multiple members of the team travel across the country and around world to share their expertise on a number of technologies. All Falafel Software team members spend their days, and often their nights, helping design and build cutting edge solutions for our customers. Their technical presentations draw from these real world experiences and are assembled, practiced, and presented in what little spare time they have. That’s why we call them “Rock Stars”.

This weekend at Silicon Valley Code Camp, Falafel’s entire team from around the ...
If you have used WCF RIA Services along with Entity Framework for Silverlight applications, you know how useful they are for performing database operations from your application.  With the WCF RIA Services Toolkit, it gives you even more flexibility to expose your RIA DomainService methods to not only a Silverlight application, but any application that can access a SOAP or JSON endpoint.
I will provide some steps here for setting up and consuming data through a SOAP endpoint.

1. Install WCF RIA Services Toolkit

You will need to install the toolkit in your development environment.  You can get it here...

I have seen an interesting and sometimes annoying side effect of using Silverlight binding on string properties that makes them turn from a null string to an empty (length 0) string. Typically my bindings are bound to WCF RIA Services entities that can have a nullable string. By simply selecting and then unselecting a TextBox that is bound to a nullable string in an entity will cause it to become an empty string.

 

This wasn’t what I wanted to happen. I need strings that have been changed to empty to stay null if and only if the underlying entity ...

This week our CEO, Lino Tadros, is the special guest on  the popular .NET development show, “Yet Another Podcast”. The show is hosted by Jesse Liberty, a Senior Developer-Community Evangelist on the Windows Phone Team. Jesse and Lino discuss developing applications for Windows Phone, MVVM, Silverlight, Visual Studio 11 and more. Lino also makes a big promotional offer during the interview, so if you are itching to learn a little bit about Windows Phone, you are going to want to tune in.


Grab the podcast here: http://jesseliberty.com/2012/02/06/yet-another-podcast-59lino-tadres/

My friend Basem has a nice blog post about the most useful features of the Productivity Power Tools extension for Visual Studio 2010.  It’s definitely worth a read if you haven’t read it already.  Like Basem, I love the Productivity Power Tools extension and use most of it’s features on a daily basis.  And, until recently, I’d run into only a very few issues with it, all of which I’d classify as minor annoyances. 

Recently though, I ran into one issue that put me off track for a while trying to figure it out.  It happened when I created a ...

Entity Framework can save you a lot of time when developing data operations in your application.  I am going to demonstrate some techniques to use calculated fields to filter or constrain your results in a LINQ to Entity query.

Before we get started, we’ll use a simple example of a Contact entity that has one or more Address entities associated with it:

public class Contact
{
	public int ContactId { get; set; }
	public string FirstName { get; set; }
	public string LastName { get; set; }
	public DateTime Birthday { get; set; }
	public List<Address> Addresses { get; set; }
}

public class Address
{
	public int ContactId { ...