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.
Namespace: EWSoftware.EntityFrameworkAssembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
public static string? ToStringOrNull(
this Object? value
)
<ExtensionAttribute>
Public Shared Function ToStringOrNull (
value As Object
) As String
public:
[ExtensionAttribute]
static String^ ToStringOrNull(
Object^ value
)
[<ExtensionAttribute>]
static member ToStringOrNull :
value : Object -> string
- value Object
- The value to check
StringIf the value is null,
DBNull.Value or an empty string this returns
null. If
not, it returns the string representation of the specified object.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).
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.
using var dataContext = new MyDbContext();
var resultSet = dc.spDrasticActions(dtpFromDate.Value, dtpToDate.Value,
cboActionType.SelectedValue.ToStringOrNull());