SaaS CMS has officially launched! Learn more now.

Class Converter

Helper functions for common converter scenarios

Inheritance
System.Object
Converter
Namespace: EPiServer.DataAbstraction.Internal
Assembly: EPiServer.dll
Version: 12.0.3
Syntax
public class Converter : Object

Constructors

Converter()

Declaration
public Converter()

Methods

ToIntZero(Object)

Returns 0 if parameter is anything else than of type System.Int32, also supports converting of False to 0 and True to 1.

Declaration
public static int ToIntZero(object val)
Parameters
Type Name Description
System.Object val
Returns
Type Description
System.Int32

ToStringEmpty(Object)

Returns String.Empty if parameter is anything else than of type System.String.

Declaration
public static string ToStringEmpty(object val)
Parameters
Type Name Description
System.Object val
Returns
Type Description
System.String

ToStringNull(Object)

Tries to cast to a string.

Declaration
public static string ToStringNull(object val)
Parameters
Type Name Description
System.Object val

The object to cast.

Returns
Type Description
System.String

val cast to a string if it is a string, otherwise null.

ToSystemNull(Object)

Converts from System.DBNull to null.

Declaration
public static object ToSystemNull(object val)
Parameters
Type Name Description
System.Object val

The object to convert.

Returns
Type Description
System.Object

null if val is System.DBNull, otherwise val unchanged.

Extension Methods