Click or drag to resize

DataReadListpDataModel Method

Reads records from database and fill a list of data model class.

Namespace:  Velo.Data.Database
Assembly:  Velo.Data (in Velo.Data.dll) Version: 22.2.10.1 (22.2.10.450)
Syntax
internal static List<pDataModel> ReadList<pDataModel>(
	string pSQLStatement,
	string pConnectionString = ""
)
where pDataModel : new()

Parameters

pSQLStatement
Type: SystemString
SQL statement
pConnectionString (Optional)
Type: SystemString
Database connection string

Type Parameters

pDataModel
Data model class to fill

Return Value

Type: ListpDataModel
Gives a list of data item
Remarks
Read records from database as equal of SQL statement, example from WHERE with LIKE.

The class must has a constructor method with a SQL data reader as parameter.

Examples
An example of get by ID
public static List<Models.BikeHistory> GetByBikeNumber(string pBikeNumber, string pConnectionString = "")
{
    try
    {
        string lSQLStatement = Velo.Data.BikeHistory.GetSQLSelectJoinBike +
            $" WHERE Bike.Number like '%{pBikeNumber}%'" +
            " ORDER BY [Bike].[Number], [Bike].[Brand], [Bike].[Type];";
        return Velo.Data.Database.Data.ReadList<Velo.Data.Models.BikeHistory>(pSQLStatement: lSQLStatement, pConnectionString: pConnectionString);
    }
    catch (Exception lException)
    {
        //* debug information *
        System.Diagnostics.Debug.WriteLine("#Exception: " + lException.Message);
        throw;
    }
}
See Also