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"
...
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...
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 ...
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...
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...
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 ...
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...
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.
...
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 ...
How to find out column with NULL values allowed in the insert in whole database ?
...
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...
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.
...
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...
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 <...
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...
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...
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 ...
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(
...
in sql server enterprise manager, how do you write an insert statement with passing in null values
...
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.
...