1 c# linq casting executequery
我有以下声明:
someList = dc.ExecuteQuery<MyCustomType>(@"Select Id As ProductId, Name From ivProduct").ToList();
Run Code Online (Sandbox Code Playgroud)
当我的MyCustomType的Id属性为INT时,数据库中的Id存储为int32.有没有办法在选择期间将int32强制转换为int?
谢谢
int并且Int32是相同的类型.不需要演员阵容.
编辑
如果您的列是a smallint,则对应于Int16(或short使用C#关键字).您可以CONVERT像现在一样使用该语句,也可以将对象的属性更改为short.