DatabaseExtensionsToStringOrNull Method

This is used to convert an object to a string and return either the string value if not empty, or null if it is an empty string.

Definition

Namespace: EWSoftware.EntityFramework
Assembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
public static string? ToStringOrNull(
	this Object? value
)

Parameters

value  Object
The value to check

Return Value

String
If the value is null, DBNull.Value or an empty string this returns null. If not, it returns the string representation of the specified object.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Object. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This is useful for passing object values to database context methods when the value needs to be stored as a null value rather than an empty string.

Example

C#
using var dataContext = new MyDbContext();

var resultSet = dc.spDrasticActions(dtpFromDate.Value, dtpToDate.Value,
    cboActionType.SelectedValue.ToStringOrNull());

See Also