null

Serialize nullable fields from an object c#

I am trying to serialize an object that has nullable fields. If the field doesn't have any data in it the field is dropped from the serialized output. Any suggests on how to work around this? Is there a way to specify that nullable empty fields still get carried over? This occurs when "propertyname_specified = false" ...

ASP.NET MVC, strongly typed views, partial view parameters glitch.

If i got view which inherits from: System.Web.Mvc.ViewPage<Foo> Where Foo has a property Bar with a type string And view wants to render strongly typed partial view which inherits from: System.Web.Mvc.ViewUserControl<string> like this: Html.RenderPartial("_Bar", Model.Bar);%> Then why it will throw this: The model item...

Is there a way I can send a NULL value to a SQL stored proc through XML?

I'm wondering if there is a way I can send a NULL or DBNull.Value from my C# data service to a stored proc through some configuration xml parameter. In the proc, I want to pull some values out of the xml as a bit but because the UI allows for a third state, the bit value coming in from the xml can be NULL in which case I want to ignore ...

Why is this mysql table producing a NULL in the datetime field?

I've got this table. The table has a bunch of char fields, but the field in question (expiredate) contains a char on the test_tmp table, and a datetime on the test table. (Table names have been changed to protect the clients.) In the test_tmp table, the field contains a Month-Date pair, like 'Aug 10' or 'Feb 20'. The code I'm using t...

Python SQL Select with possible NULL values

Hi, I'm new to python and have hit a problem with an SQL query I'm trying to perform. I am creating an SQL SELECT statement that is populated with values from an array as follows: ret = conn.execute('SELECT * FROM TestTable WHERE a = ? b = ? c = ?', *values) This works ok where I have real values in the values array. However in some...

Unable to add a "NOT NULL" column to empty table in SQL Server

I understand that when adding a column to a table containing data in SQL server, the column must have a NULL option or a default. Otherwise what would SQL Server pad the new rows with? I am at a loss as to why I can't add a NOT NULL column to an empty table however. I have tried this on two instances of SQL 2008 and one instance of SQL ...

How to implement List, Set, and Map in null free design?

Its great when you can return a null/empty object in most cases to avoid nulls, but what about Collection like objects? In Java, Map returns null if key in get(key) is not found in the map. The best way I can think of to avoid nulls in this situation is to return an Entry<T> object, which is either the EmptyEntry<T>, or contains the va...

null shorthand in C#?

Is there a way to make this line shorter? bool pass = d != null && d["k"] != null && (bool)d["k"]; Note: "k" is actually "a longer id"; I replaced it to make it more readable in this post. Many of your suggestions don't check whether d is null. ...

How do I in JDBC read a possibly null double value from resultSet?

I have a column in my database that is typed double and I want to read the value from it using a JDBC ResultSet, but it may be null. What is the best way of doing this? I can think of three options none of which seem very good. Option 1: Bad because exception handling verbose and smelly double d; try { d = rs.getDouble(1); // do ...

Finding all Nullable Columns in SQL 2000 Database

How to find out column with NULL values allowed in the insert in whole database ? ...

Capturing output of find . -print0 into a bash array

Using find . -print0 seems to be the only safe way of obtaining a list of files in bash due to the possibility of filenames containing spaces, newlines, quotation marks etc. However, I'm having a hard time actually making find's output useful within bash or with other command line utilities. The only way I have managed to make use of th...

Is there an option to make Entity Framework revert empty strings to null?

Hi I am using an ADO.NET Entity-Framework ObjectContext to access my data store. I want the if values are set with empty strings, they should automatically become null. ...

C# Shortest Way to Check for Null and Assign Another Value if Not

I am pulling varchar values out of a DB and want to set the string I am assigning them to as "" if they are null. I'm currently doing it like this. if (IsNullOrEmpty(planRec.approved_by) == true) this.approved_by = ""; else this.approved_by = planRec.approved_by.toString(); There seems like there should be a way to do this in a s...

Negating an arbitrary where clause condition (including the null tests)

I want to efficiently check if a table contains any rows that match <condition A> and do not match <condition B>, where the conditions are arbitrary. In Oracle, this almost works: select count(*) from dual where exists ( select * from people where (<condition A>) and not (<condition B>) ); -- returns zero if all rows that match <...

Retrieve a list containing NULLS with Linq

Is it possible to use LINQ to retrieve a list that may contain nulls. For example if I have a left outer join like so: var query= from c in db.Customers join o in db.Orders on c.CustomerID equals o.CustomerID into sr from x in sr.DefaultIfEmpty() select x.OrderId; Ho...

nullobject for File in Java

I have a class that occasionally gets passed null for File objects. During normal operation it uses a Scanner class to parse through the file. Instead of littering my code with null checks against the File objects, I thought I could replace the Files with nullobjects (Gang of Four style). However, it looks like File isn't really design...

Flex PopUp Window Mate Listener and null object reference

There is a similar post here regarding this issue, but my problem is a little different. I have a PopUp window containing a form used to sign-up for access to a site. An event is generated from the PopUp via a Mate Dispatcher tag (Figure 1) validated in Flex and then sent to the server. Validation happens both in Flex and on the remote ...

GetCustomAttribute() returns null for AssemblyVersionAttribute

I'm adding an About dialog to my .NET application and I'm querying the assembly's attributes for information to display. When I attempt to retrieve my assembly's AssemblyVersionAttribute using GetCustomAttribute() it returns null: // Works fine AssemblyTitleAttribute title = (AssemblyTitleAttribute)Attribute.GetCustomAttribute( ...

how do you insert null values into sql server

in sql server enterprise manager, how do you write an insert statement with passing in null values ...

Why doesn't C terminate strings with a special escaped string-termination character?

In C, strings are terminated with null ( \0 ) which causes problems when you want to put a null in a strings. Why not have a special escaped character such as \$ or something? I am fully aware at how dumb this question is, but I was curious. ...