无法将类型“System.Collections.Generic.List<anonymous type:string ClassID,string ClsssName>”隐式转换为“System.Collections.Generic.List<Ecology.Model.EnergyFlowGraph>” 一.EF应用中,常见类型转换问题解决方案 public List<EnergyFlowGraph> GetData() { var data = db.Energ…
[隐式类型局部变量] 可以赋予局部变量推断“类型”var 而不是显式类型.var 关键字指示编译器根据初始化语句右侧的表达式推断变量的类型.推断类型可以是内置类型.匿名类型.用户定义类型或 .NET Framework 类库中定义的类型. // i is compiled as an int ; // s is compiled as a string var s = "Hello"; // a is compiled as int[] , , }; // expr is compil…