2010-04-22 5 views
0

을 변환 할 수 없습니다.암시 적으로이 코드를 입력 ...에 ... 문제

Error 1 Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<ConnectionWeb.Customer>' to 'System.Collections.Generic.IEnumerable<ConnectionWeb.DAL.dcCustomer>'. An explicit conversion exists (are you missing a cast?) \\srv01\home$\Z****\Visual Studio 2008\Projects\ConnectionWeb\ConnectionWeb\DAL\dcCustomer.cs 63 20 ConnectionWeb 

열거 자의 값을 유지하고 반환하도록 myCustomerList를 가져 오려고합니다.

답변

2

문제가 당신이 DAl.dcCustome R 형식을 반환 할 것으로 예상된다이지만, LINQ 문이 ConnectionWeb.Customer 유형을 반환 ...

당신은 변경하여이 문제를 극복 할 수 :

IEnumerable<dcCustomer> myCustomerList = 
(from Customer res 
    db.Customers 
    where res.CompanyName == Companyname 
    select res); 

에 :

IEnumerable<dcCustomer> myCustomerList = (from Customer res 
    in db.Customers 
    where res.CompanyName == Companyname 
    select new dcCustomer(){ 
    //set properties here... 
    }); 

HTH

+0

답변 해 주셔서 감사합니다. – Younes

1

db.Customers에는 ConnectionWeb.DAL.dcCustomer가 아닌 ConnectionWeb.Customer 유형의 객체가 있다고 가정합니다.