私はC#で、このモデルを持っている:どうすれば解決できますか?System.Collections.Generic.List型を暗黙的に変換できませんか?
public class interfaceModel
{
public string interfacename { get; set; }
public long id { get; set; }
}
と、このコードを書く:
public static List<interfaceModel> CompanyInterfaceFetch()
{
var database = new DataBaseDataContext();
var companyinterface = new CompanyInterface();
var interfacelist =
database.CompanyInterfaces.Select(x => new interfaceModel { interfacename = x.InterfaceName, id=x.id});
return interfacelist.ToList();
}
// database model
public class interfaceModel
{
public string interfacename { get; set; }
public long id { get; set; }
}
今、私は、そのメソッドを呼び出すコードを記述します。
public static List<interfaceModel> interfacefetch()
{
return Database.CompanyInterfaceFetch();
}
が、この行に:
return Database.CompanyInterfaceFetch();
私はこのエラーを受け取ります:
Error CS0029: Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Collections.Generic.List
どうすればこの問題を解決できますか?ありがとう。
次の2つの 'interfaceModel'を持っているのですか? DanielA.White @ –
にはちょうど1 interfaceModel –
コンパイラはあなたが –