atorres@processa.com (1) [Avatar] Offline
#1
I have a stored procedure that returns two columns. The first is Timestamp (nullable) and the second is Integer (nullable).

I have a method in my DataContext to execute this function, as follows:

[Function(Name = "SpName")]
public ISingleResult<MyClass2> My2AuthorizedTransactionsBOGrid(
[Parameter(Name = "IdCardProgram", DbType = "Int")] int idCardProgram,
[Parameter(Name = "IdUser", DbType = "Int")] int idUser)
{
IExecuteResult result =
this.ExecuteMethodCall(
this,
((MethodInfo) (MethodInfo.GetCurrentMethod())),
idCardProgram,
idUser);

return ((ISingleResult<MyClass2>smilie (result.ReturnValue));
}


I have a class that I use to populate the results, as follows:

public class MyClass2
{
[Column(DbType = "Int", Name = "Flag")]
public bool? IsRelated
{
get;
set;
}

[Column(DbType = "rowversion", Name = "IdTimer")]
public Binary RowId
{
get;
set;
}
}

If I placed the Rowid property under the IsRelated property, this creates an exception InvalidCastException, Cannot cast from 'System.DBNull' type to 'System.Byte[]' type.

If I placed the Rowid property below the IsRelated property, everything works fine.

How important is the order in which the properties are placed in the source file? The fact that I had never happened before.