CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
SafeSqlDataReader.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="SafeSqlDataReader.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>This is a SqlDataReader based on SafeDataReader</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Data;
10#if NETFX
11using System.Data.SqlClient;
12#else
13using Microsoft.Data.SqlClient;
14#endif
15using System.Threading.Tasks;
16
17namespace Csla.Data.SqlClient
18{
24 {
30
36 public SafeSqlDataReader(IDataReader dataReader)
37 :base(dataReader)
38 {
40 }
41
48 public Task<T> GetFieldValueAsync<T>(int ordinal)
49 {
50 if (SqlDataReader == null)
51 throw new NotSupportedException("GetFieldValueAsync");
52 return SqlDataReader.GetFieldValueAsync<T>(ordinal);
53 }
54
61 public Task<T> GetFieldValueAsync<T>(int ordinal, System.Threading.CancellationToken cancellationToken)
62 {
63 if (SqlDataReader == null)
64 throw new NotSupportedException("GetFieldValueAsync");
65 return SqlDataReader.GetFieldValueAsync<T>(ordinal, cancellationToken);
66 }
67
74 public Task<bool> IsDbNullAsync(int ordinal)
75 {
76 if (SqlDataReader == null)
77 throw new NotSupportedException("IsDbNullAsync");
78 return SqlDataReader.IsDBNullAsync(ordinal);
79 }
80
88 public Task<bool> IsDbNullAsync(int ordinal, System.Threading.CancellationToken cancellationToken)
89 {
90 if (SqlDataReader == null)
91 throw new NotSupportedException("IsDbNullAsync");
92 return SqlDataReader.IsDBNullAsync(ordinal, cancellationToken);
93 }
94
99 public Task<bool> NextResultAsync()
100 {
101 if (SqlDataReader == null)
102 throw new NotSupportedException("NextResultAsync");
103 return SqlDataReader.NextResultAsync();
104 }
105
111 public Task<bool> NextResultAsync(System.Threading.CancellationToken cancellationToken)
112 {
113 if (SqlDataReader == null)
114 throw new NotSupportedException("NextResultAsync");
115 return SqlDataReader.NextResultAsync(cancellationToken);
116 }
117
122 public Task<bool> ReadAsync()
123 {
124 if (SqlDataReader == null)
125 throw new NotSupportedException("NextResultAsync");
126 return SqlDataReader.ReadAsync();
127 }
128
134 public Task<bool> ReadAsync(System.Threading.CancellationToken cancellationToken)
135 {
136 if (SqlDataReader == null)
137 throw new NotSupportedException("NextResultAsync");
138 return SqlDataReader.ReadAsync(cancellationToken);
139 }
140 }
141}
This is an IDataReader that 'fixes' any null values before they are returned to our business code.
IDataReader DataReader
Get a reference to the underlying data reader object that actually contains the data from the data so...
This is a SqlDataReader that 'fixes' any null values before they are returned to our business code.
Task< bool > NextResultAsync(System.Threading.CancellationToken cancellationToken)
Advances the reader to the next result.
SqlDataReader SqlDataReader
Get a reference to the underlying SqlDataReader if present.
SafeSqlDataReader(IDataReader dataReader)
Initializes the SafeDataReader object to use data from the provided DataReader object.
Task< bool > IsDbNullAsync(int ordinal)
Gets a value indicating whether the column has a null or missing value.
Task< bool > ReadAsync()
Advances to the next record in a recordset.
Task< bool > IsDbNullAsync(int ordinal, System.Threading.CancellationToken cancellationToken)
Gets a value indicating whether the column has a null or missing value.
Task< bool > NextResultAsync()
Advances the reader to the next result.
Task< T > GetFieldValueAsync< T >(int ordinal)
Asynchronously gets the data value as a type.
Task< bool > ReadAsync(System.Threading.CancellationToken cancellationToken)
Advances to the next record in a recordset.