Question

I have the following statement:

someList = dc.ExecuteQuery<MyCustomType>(@"Select Id As ProductId, Name From ivProduct").ToList();

Id in the database is stored as int32, when my Id property of MyCustomType is INT. Is there a way to cast that int32 to int during a select?

Thank you

Was it helpful?

Solution

int and Int32 are the same type. No cast is necessary.

Edit

If your column is a smallint, that corresponds to an Int16 (or short using the C# keyword). You can either use the CONVERT statement as you are now, or you can change the property on your object to be a short.

OTHER TIPS

Doing Convert(INT,Id) As ProductId did the job. Would be good to see a way to do it without SQL Convert. Might try adding cast to properties

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top