Class DataHelper
This class contains methods for validating, converting and manipulating data types commonly used in applications.
Inherited Members
Namespace: DataWeb.Data
Assembly: DataWeb.Core.dll
Syntax
public static class DataHelper
  Methods
ConvertStringToValue(string, string)
Converts the specified string representation to the specified data type.
Declaration
public static object ConvertStringToValue(string stringValue, string dataType)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | stringValue | The string representation of the value to convert.  | 
      
| string | dataType | The data type to convert the string value to. Valid values are "Boolean", "Integer", "Decimal", "Date", "DateTime", "DateTimeOffset" and "String".  | 
      
Returns
| Type | Description | 
|---|---|
| object | The converted value.  | 
      
ConvertValueToString(object, string)
Converts the specified value to a string representation of the specified data type.
Declaration
public static string ConvertValueToString(object value, string dataType)
  Parameters
| Type | Name | Description | 
|---|---|---|
| object | value | The value to convert.  | 
      
| string | dataType | The data type of the value to convert. Valid values are "Boolean", "Integer", "Decimal", "Date", "DateTime", "DateTimeOffset" and "String".  | 
      
Returns
| Type | Description | 
|---|---|
| string | A string representation of the specified value.  | 
      
IsValidValue(object, string)
Determines whether the specified value can be converted to the specified data type.
Declaration
public static bool IsValidValue(object value, string dataType)
  Parameters
| Type | Name | Description | 
|---|---|---|
| object | value | The value to validate.  | 
      
| string | dataType | The data type to validate the value against. Valid values are "Boolean", "Integer", "Decimal", "Date", "DateTime", "DateTimeOffset" and "String".  | 
      
Returns
| Type | Description | 
|---|---|
| bool | True if the value can be converted to the specified data type, false otherwise.  | 
      
RemoveMilliseconds(DateTime)
Removes the milliseconds component of a DateTime value.
Declaration
public static DateTime RemoveMilliseconds(DateTime date)
  Parameters
| Type | Name | Description | 
|---|---|---|
| DateTime | date | The DateTime value to remove the milliseconds from.  | 
      
Returns
| Type | Description | 
|---|---|
| DateTime | A new DateTime value without the milliseconds component.  | 
      
RemoveMilliseconds(DateTimeOffset)
Removes the milliseconds component of a DateTimeOffset value.
Declaration
public static DateTimeOffset RemoveMilliseconds(DateTimeOffset date)
  Parameters
| Type | Name | Description | 
|---|---|---|
| DateTimeOffset | date | The DateTimeOffset value to remove the milliseconds from.  | 
      
Returns
| Type | Description | 
|---|---|
| DateTimeOffset | A new DateTimeOffset value without the milliseconds component.  |