S
shapper
Hello,
I am trying to define a value for a statistic as follows:
FilesPerMonth = db.Files.Count() /
(float)((DTH.Span(DI.Month, db.Files.Min(f =>
f.CreatedAt), DateTime.Now) ?? 1) == 0 ? 1 :
DTH.Span(DI.Month, db.Files.Min(f =>
f.CreatedAt), DateTime.Now).Value),
FilesPerMonth is a float
Basically, I check if DTH.Span returns null ... if it does I define a
default value = 1.
If not I check if the value is 0. If yes I give it the value 1 to
prevent division by 0.
Otherwise I use the returned value.
my DTH.Span function is:
public static long? Span(DateInterval interval, DateTime? from,
DateTime? to)
I am using this inline code because I am using this on a Linq Query.
Does anyone knows what I am doing wrong. I chenged my code many times
but I keep having the same problem:
"Nullable object must have a value."
I though I had preview all possible situations on my code but I am
missing something.
Thank You,
Miguel
I am trying to define a value for a statistic as follows:
FilesPerMonth = db.Files.Count() /
(float)((DTH.Span(DI.Month, db.Files.Min(f =>
f.CreatedAt), DateTime.Now) ?? 1) == 0 ? 1 :
DTH.Span(DI.Month, db.Files.Min(f =>
f.CreatedAt), DateTime.Now).Value),
FilesPerMonth is a float
Basically, I check if DTH.Span returns null ... if it does I define a
default value = 1.
If not I check if the value is 0. If yes I give it the value 1 to
prevent division by 0.
Otherwise I use the returned value.
my DTH.Span function is:
public static long? Span(DateInterval interval, DateTime? from,
DateTime? to)
I am using this inline code because I am using this on a Linq Query.
Does anyone knows what I am doing wrong. I chenged my code many times
but I keep having the same problem:
"Nullable object must have a value."
I though I had preview all possible situations on my code but I am
missing something.
Thank You,
Miguel