Utility library for common data operations.
Westwind.Utilities.DataUtils
public static class DataUtils : object
Class Members
Member | Description | |
---|---|---|
MinimumSqlDate |
The default SQL date used by InitializeDataRowWithBlanks. Considered a blank date instead of null. | |
CopyDataRow |
Copies the content of a data row to another. Runs through the target's fields and looks for fields of the same name in the source row. Structure must mathc or fields are skipped. public static bool CopyDataRow(DataRow source, DataRow target) |
|
CopyObjectData |
Copies the content of one object to another. The target object 'pulls' properties of the first. public static void CopyObjectData(object source, object target) public static void CopyObjectData(object source, object target, BindingFlags memberAccess) public static void CopyObjectData(object source, object target, string excludedProperties) public static void CopyObjectData(object source, object target, string excludedProperties, BindingFlags memberAccess) |
|
CopyObjectFromDataRow |
Populates an object passed in from values in a data row that's passed in. public static void CopyObjectFromDataRow(DataRow row, object targetObject, MemberInfo[] cachedMemberInfo) |
|
CopyObjectToDataRow |
Copies the content of an object to a DataRow with matching field names. Both properties and fields are copied. If a field copy fails due to a type mismatch copying continues but the method returns false public static bool CopyObjectToDataRow(DataRow row, object target) |
|
DataReaderToIEnumerable |
Creates an IEnumerable of T from an open DataReader instance. public static IEnumerable |
|
DataReaderToList |
public static List |
|
DataReaderToObject |
Populates the properties of an object from a single DataReader row using Reflection by matching the DataReader fields to a public property on the object passed in. Unmatched properties are left unchanged. public static void DataReaderToObject(IDataReader reader, object instance, string propertiesToSkip, Dictionary<String,PropertyInfo> piList) |
|
DataReaderToObjectList |
Creates a list of a given type from all the rows in a DataReader. public static List |
|
DataTableToObjectList |
Coverts a DataTable to a typed list of items public static List |
|
DataTableToTypedList |
Coverts a DataTable to a typed list of items public static List |
|
DbTypeToDotNetType |
Maps a DbType to a .NET native type public static Type DbTypeToDotNetType(DbType sqlType) |
|
DotNetTypeToDbType |
Converts a .NET type into a DbType value public static DbType DotNetTypeToDbType(Type type) |
|
DotNetTypeToSqlType |
Converts a .NET type into a SqlDbType. public static SqlDbType DotNetTypeToSqlType(Type type) |
|
GenerateUniqueId |
Generates a unique Id as a string of up to 16 characters. Based on a GUID and the size takes that subset of a the Guid's 16 bytes to create a string id. public static string GenerateUniqueId(int stringSize, string additionalCharacters) |
|
GenerateUniqueNumericId |
Generates a unique numeric ID. Generated off a GUID and returned as a 64 bit long value public static long GenerateUniqueNumericId() |
|
GetRandomNumber |
Returns a random integer in a range of numbers a single seed value. public static int GetRandomNumber(int min, int max) |
|
IndexOfByteArray |
Returns an index into a byte array to find sequence of of bytes. Note: You can use Span.IndexOf() where available instead. public static int IndexOfByteArray(Byte[] buffer, Byte[] bufferToFind) public static int IndexOfByteArray(Byte[] buffer, string stringToFind, Encoding encoding) |
|
InitializeDataRowWithBlanks |
Initializes a Datarow containing NULL values with 'empty' values instead. Empty values are: String - "" all number types - 0 or 0.00 DateTime - Value of MinimumSqlData (1/1/1900 by default); Boolean - false Binary values and timestamps are left alone public static void InitializeDataRowWithBlanks(DataRow row) |
|
RemoveBytes |
Removes a sequence of bytes from a byte array public static Byte[] RemoveBytes(Byte[] buffer, Byte[] bytesToRemove) |
|
SqlTypeToDotNetType |
Maps a SqlDbType to a .NET type public static Type SqlTypeToDotNetType(SqlDbType sqlType) |
Requirements
Namespace: Westwind.UtilitiesAssembly: westwind.utilities.dll
© West Wind Technologies, 1996-2024 • Updated: 06/29/24
Comment or report problem with topic