views:

10

answers:

1

Hi

I have an object Customer with a 1-n relationship to Addresses.

I want to be able to take the first address. So i create a method:

public Address firstAddress
{
     get
     {
         var f=from d in this.Addresses
               select d;
         return f;
     }
} 

I get the following error :

Error 5 Impossible to find an implementation ofsource 'System.Data.Objects.DataClasses.EntityCollection'. 'Select' introuvable. Une référence à 'System.Core.dll' ou une directive using pour 'System.Linq' est-elle manquante ?

I do not undertand why i can't query the collection of addresses... Thanks John

A: 

Well, the error message tells you where to start looking, presuming you can read French. :) Make sure your app has a reference to the System.Core assembly and your code file has using System.Linq; at the top.

Also, I think the query is wrong. I'm presuming that this.Addresses is an enumeration of the type Address. In this case you'd need:

public Address firstAddress
{
     get
     {
         var f=(from d in this.Addresses
                select d).FirstOrDefault();
         return f;
     }
} 
Craig Stuntz