Operation could destabilize the runtime?

前端 未结 11 1583
执念已碎
执念已碎 2020-11-28 09:31

I\'m having a little bit of trouble understanding what the problem is here. I have a bit of code that pulls records from a database using LINQ and puts them into an object

11条回答
  •  佛祖请我去吃肉
    2020-11-28 10:26

    Does it still fail if you change this:

    select new SomeObject { ... } as ISomeTable;
    

    to this:

    select (ISomeTable) new SomeObject { ... };
    

    ?

    If so (as I see you've confirmed), perhaps this has to do with the fact that an interface implementation could be either a class or a struct? Does the problem still appear if you cast to an abstract class rather than an interface?

提交回复
热议问题