[Lambda]Problèmes avec les lambdas expressions
Voici mon code :
Code:
1 2 3 4 5 6 7 8
| public List<Customers> GetCustomersLambda(string city)
{
NorthwindDataContext db = new NorthwindDataContext();
var truc2 = db.Customers.Where(c => c.City.StartsWith(city)).Select(c=>new {c.ContactName,c.Country});
return truc2.ToList();
} |
je ne veux retourner que le pays avec linq c'est nickel mais ne peut-on le faire avec les lambdas expressions ?
Voici l'erreur qu'il me sort :
Code:
1 2 3 4
| <div class="bbcode_container">
<div class="bbcode_description">Code:</div>
<hr /><code class="bbcode_code">Erreur <span style="color: #cc66cc;">1</span> Impossible de convertir implicitement le type <span style="color: #FF0000;">'System.Collections.Generic.List<AnonymousType#1>'</span> en <span style="color: #FF0000;">'System.Collections.Generic.List<SLBindingDatabaseWeb.Customers>'</span> D:\Mes documents\Visual Studio <span style="color: #cc66cc;">2008</span>\Projects\SLBindingDatabase\SLBindingDatabaseWeb\Service1.svc.cs <span style="color: #cc66cc;">33</span> <span style="color: #cc66cc;">20</span> SLBindingDatabaseWeb</code><hr />
</div> |
Merci de votre aide