DataReadpDataModel Method |  |
Reads one record from database and fill data model class.
Namespace:
Velo.Data.Database
Assembly:
Velo.Data (in Velo.Data.dll) Version: 22.2.10.1 (22.2.10.450)
Syntaxinternal static pDataModel Read<pDataModel>(
string pSQLStatement,
string pConnectionString = ""
)
where pDataModel : new()
Friend Shared Function Read(Of pDataModel As New) (
pSQLStatement As String,
Optional pConnectionString As String = ""
) As pDataModel
Parameters
- pSQLStatement
- Type: SystemString
SQL statement - pConnectionString (Optional)
- Type: SystemString
Database connection string
Type Parameters
- pDataModel
- Data model class to fill
Return Value
Type:
pDataModelGives a data item
Remarks
Read first record from database as equal of SQL statement, example from WHERE.
The class must has a constructor method with a SQL data reader as parameter.
Examples
An example of get by ID
public static Models.BikeHistory GetByID(int pID, string pConnectionString = "")
{
try
{
string lSQLStatement = Velo.Data.BikeHistory.GetSQLSelect + $" WHERE ID='{pID}';";
return Velo.Data.Database.Data.Read<Velo.Data.Models.BikeHistory>(pSQLStatement: lSQLStatement, pConnectionString: pConnectionString);
}
catch (Exception lException)
{
System.Diagnostics.Debug.WriteLine("#Exception: " + lException.Message);
throw;
}
}
See Also