SubSonic ActiveRecord templates: generated code produces error converting int? to int
I just started exploring SubSonic 3's ActiveRecord, and it's initial code generation has created errors.
Cannot implicitly convert type 'int?' to 'int'.
An 开发者_JAVA技巧explicit conversion exists (are you missing a cast?)
Here's the line it throws the exception on:
public override int GetHashCode() {
return this.pkEmp;
}
The exception is understandable since the column pkEmp
is defined as int? _pkEmp;
. Any ideas on why the two are out of sync?
There can be no null value in the column defined as primary key. If so, make sure you have a problem with join (if the entity comes from a "View").
As John Sheehan pointed out, it's important to make sure that any primary keys are not nullable (and why would they be?).
精彩评论