nullable

sql server bulk insert nulls into time column

一笑奈何 提交于 2020-01-03 09:23:28
问题 I'm having trouble inserting null value from a bulk insert statement. Two columns are nullable and the Id is identity. The int nullable workd out fine, but the time doesn't. Here the bulk statement: BULK INSERT Circulation FROM '.....file.cs' WITH ( FIRSTROW = 2, MAXERRORS = 0, FIELDTERMINATOR = ',', ROWTERMINATOR = '', KEEPNULLS) Here is an extract of the csv: ID, IDStopLine, IDException, Hour, PositionHour, Day ,28, 8, 12:20, 52, 0 ,29, 163, , 1, Meaning that I'm trying to insert nulls in

Overloading Controller Actions

删除回忆录丶 提交于 2020-01-03 08:38:15
问题 I was a bit surprised a few minutes ago when I tried to overload an Action in one of my Controllers I had public ActionResult Get() { return PartialView(/*return all things*/); } I added public ActionResult Get(int id) { return PartialView(/*return 1 thing*/); } .... and all of a sudden neither were working I fixed the issue by making 'id' nullable and getting rid of the other two methods public ActionResult Get(int? id) { if (id.HasValue) return PartialView(/*return 1 thing*/); else return

Is there a non-messy way to chain the results of functions that return Option values?

99封情书 提交于 2020-01-03 08:14:51
问题 I have some code that looks like this: f(a).and_then(|b| { g(b).and_then(|c| { h(c).map(|d| { do_something_with(a, b, c, d) }) }) }) Where f , g , and h return Option values. I need to use all the intermediate values ( a , b , c , and d ) in the do_something_with calculation. The indentation is very deep. Is there a better way to do this? Ideally it would look something like this (which of course doesn't work): try { let b = f(a); let c = g(b); let d = h(c); do_something_with(a, b, c, d) }

Why can't I cast generic-type with null? [duplicate]

邮差的信 提交于 2020-01-03 06:39:42
问题 This question already has answers here : Why cannot convert null to type parameter T in c#? (3 answers) Closed last month . A similar question, but without casting the T parameter. This does not work public T GetValueG<T>(string Query) { object value = DBNull.Value; // Read from Database which can return DBNull if (value is DBNull) return (T)null; else return (T)value; } Error CS0037 Cannot convert null to 'T' because it is a non-nullable value type But this works public T GetValueG<T>(string

Are nullable foreign keys allowed in Entity Framework 4?

蓝咒 提交于 2020-01-02 03:12:10
问题 I have a problem updating a foreign key in an Entity Framework entity. I am using self tracking entities and have an entity with some relations where the foreign key is also present as a property (one of the new features of EF4). The key (an integer) is marked as Nullable and Concurrency Mode fixed. Specifically I have an Alarm entity with a many to 0..1 relationship to a confirming user. (a user may confirm several alarms, but an alarm can be confirmed by only zero or one users). The entity

Adding detectable Nullable values to CsvHelper

人盡茶涼 提交于 2020-01-02 01:56:08
问题 I was wondering if CsvHelper by Josh Close has anything in the configuration I am missing to translate values to null. I am a huge fan of this library, but I always thought there should be some sort of configuration to let it know what values represent NULL in your file. An example would be a column with the value "NA", "EMPTY", "NULL", etc. I am sure I could create my own TypeConverter, but I was hoping there would be an easier option to set somewhere in a config as this tends to be fairly

Why does Nullable<T> not match as a reference type for generic constraints [duplicate]

放肆的年华 提交于 2020-01-01 07:36:05
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Nullable type as a generic parameter possible? I came across a very weird thing with generic type constraints. I have a class like this: public SomeClass<T> where T:class { } However, I've found I can't use nullable types as I'd expect: new SomeClass<int?>(); I get an error that int? must be a reference type. Is Nullable really just a struct with syntactic sugar to make it look like a reference type? 回答1:

How to compare nullable types?

梦想与她 提交于 2019-12-31 08:54:13
问题 I have a few places where I need to compare 2 (nullable) values, to see if they're the same. I think there should be something in the framework to support this, but can't find anything, so instead have the following: public static bool IsDifferentTo(this bool? x, bool? y) { return (x.HasValue != y.HasValue) ? true : x.HasValue && x.Value != y.Value; } Then, within code I have if (x.IsDifferentTo(y)) ... I then have similar methods for nullable ints, nullable doubles etc. Is there not an

How to convert type int[] to int?[]

点点圈 提交于 2019-12-31 04:34:25
问题 I'm using a linq query to output an int array. But I need to pass this into a method that only accepts int?[]. So after searching on ways to convert int[] to int?[] I found something that seemed might work here The following code is a simplified example that shows what is working and not working. using System; using System.Collections.Generic; using System.Web; using System.Linq; namespace ConsoleApp { class Program { static void Main(string[] args) { // working... int[] vids1 = new[] { "",

Guice @Nullable annotation

吃可爱长大的小学妹 提交于 2019-12-31 00:41:09
问题 In my service, I have a protected constructor with @Inject and one of the parameters (provider) @Nullable . Any ideas why I am getting com.google.inject.CreationException: Guice creation errors: 1) No implementation for [[service]] was bound. ? Guice is 3.0pre1, @Nullable is ours. 回答1: @Nullable isn't the same as @Inject(optional=true) ... I think if you want to inject null , you need to bind(Service.class).toProvider(Providers.<Service>of(null)) or to otherwise have some kind of provider