Deal of the Day

Home » Main » Manning Forums » 2007 » LINQ in Action

Thread: How important is the order of properties in the source file?

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 0 - Pages: 1

Posts: 1
From: mexico
Registered: 9/8/09
How important is the order of properties in the source file?
Posted: Sep 8, 2009 7:19 PM
  Click to reply to this thread Reply

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 =
((MethodInfo) (MethodInfo.GetCurrentMethod())),

return ((ISingleResult<MyClass2>) (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

[Column(DbType = "rowversion", Name = "IdTimer")]
public Binary RowId

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.

Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Manning Developmental Editor