| IDatabaseGetRecords Method |
Returns an enumeration of the SQL records associated with the specified SQL query.
Namespace:
AskiaFieldCom.SqlDatabase
Assembly:
AskiaFieldCom (in AskiaFieldCom.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax IEnumerable<IRecord> GetRecords(
string sql,
IDictionary<string, Object> parameters
)
IEnumerable<IRecord^>^ GetRecords(
String^ sql,
IDictionary<String^, Object^>^ parameters
)
Parameters
- sql
- Type: SystemString
SQL query to create the records. - parameters
- Type: System.Collections.GenericIDictionaryString, Object
List of SQL parameters to apply on the query.
Return Value
Type:
IEnumerableIRecordReturns an enumeration on the SQL records.
Remarks
This method keep the connection open until the enumeration complete.
Remarks
Unlike the IDataReader, the IRecord is not mutable and still exists after the SQL connection is closed.
Examples Read all records associated with the SQL query.
var records = db.GetRecords("SELECT * FROM [Users] WHERE [Id] IN (@ids)", new Dictionary<string, object> {
{"@ids", new List<int> {1, 2, 3}}
});
foreach(var record in records)
{
Console.WriteLine(record["FirstName"]);
}
See Also