Exception "linqToEntities"

Fermé
steve - Modifié par steve le 17/05/2010 à 15:09
Bonjour,

Je rencontre un exception de ce type :
"LINQ to Entities does not recognize the method 'Business.Entities.Volant GetVolantById(System.String)' method, and this method cannot be translated into a store expression."

J'ai donc 2 classes Entities: Voiture et Volant (codé en C# frameworks 3.5).

La Classe Voiture :
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using Business.Entities; 

namespace Business.Entities 
{ 
    public class Voiture 
    { 
        public int IdVoiture{ get; set; } 
        public Volant VolantEntity { get; set; } 
    } 
} 

La Classe Volant:
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using Business.Entities; 

namespace Business.Entities 
{ 
    public class Volant 
    { 
        public int IdVolant{ get; set; } 
        public string Description { get; set; } 
    } 
} 


et 2 Classes Manager : VoituresManager et VolantsManager.

La Classe VoituresManager :
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using Business.Entities; 

namespace Business.Manager 
{ 
    public class VoituresManager 
    { 
        public List<Voiture> GetListVoiture() 
        { 
   return (new DataAccessLayer.DataEntity().Voitures.Select( x => new Voiture() 
     { 
      IdVoiture = x.Id, 
      VolantEntity = new Business.Manager.VolantsManager().GetVolantById(x.IdVolant) 
     } 
     )).ToList(); 
        } 
    } 
} 


La Classe VolantsManager :
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using Business.Entities; 

namespace Business.Manager 
{ 
    public class VolantsManager 
    { 
        public Volant GetVolantById(string idStr) 
        { 
   int id = int.Parse(idStr); 
   return (new DataAccessLayer.DataEntity().Volants.Where(w => w.Id.Equals(id)).Select( x => new Volant() 
     { 
      IdVolant = x.Id, 
      Description = x.Description 
     } 
     )).FirstOrDefault(); 
        } 
    } 
} 


Et donc dans une console application test (program.cs : pour mes units test)
l'exception levé (écrite en dessus) s'élève à ce morceau de code :
  VolantEntity = new Business.Manager.VolantsManager().GetVolantById(x.IdVolant) 

dans VoituresManager.

Voyez-vous où est l'erreur?
En vous remerciant d'avance.