0

I've got exception about convert NULL to Int32.

I've got a table from database with nullable tinyint

[Column(Storage="_StatType", DbType="tinyint NULL")]
public StatType : int { get { _StatType; } }

(to get C# code just replace variable's type)

and after making linq select

def StartLinq = linq <#from lpi in _CfgListParIzm
    where lpi.ID_ListParIzm==drr1
    select (lpi.StatType)
#> ;

StartLinq.ToArray()[0] can't be readed if that is null :-/

mutable STT : int = 0;
try
{
    _=int.TryParse(StartLinq.ToArray()[0].ToString(), out STT);
}
catch { | _ is Exception => () /* I don't care*/ }

upper code is very poor trick :( I wont use it.

4
  • Why is this question tagged C#? Commented Mar 23, 2010 at 9:44
  • the question is about null-able integer. and I don't hope to get Nemerle answer. But maybe I do wrong :-/ Commented Mar 23, 2010 at 9:48
  • @Peter - it is sort of C#. It's also mixed with nemerle nemerle.org Commented Mar 23, 2010 at 9:49
  • 1
    Nullable types is not C# specific, its a feature of the .Net Framework. Ohwell, seems @nCdy got it right... Commented Mar 23, 2010 at 10:06

1 Answer 1

1

I don't know nemerle, but in C# you would make StatType a nullable integer (Nullable<int> aka int?) instead of a non-nullable one. That's the most logical solution - does nemerle support nullable value types?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.