本文整理汇总了C#中IDataReader.GetDateTime方法的典型用法代码示例。如果您正苦于以下问题:C# IDataReader.GetDateTime方法的具体用法?C# IDataReader.GetDateTime怎么用?C# IDataReader.GetDateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataReader
的用法示例。
在下文中一共展示了IDataReader.GetDateTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendRecordToGraphite
private void SendRecordToGraphite(string path, IDataReader myReader)
{
using (var client = new Graphite.GraphiteTcpClient(this.hostname, this.port, string.Empty))
{
while (myReader.Read())
{
var value = myReader.GetInt32(1);
var datetime = myReader.GetDateTime(0);
this.log.Debug(string.Format("Sending {2} [{0}] {1}", value, datetime, path));
client.Send(path, myReader.GetInt32(1), myReader.GetDateTime(0));
}
}
}
示例2: GetDateTime
public static DateTime GetDateTime(IDataReader dr, string columnName)
{
int ordinal = dr.GetOrdinal(columnName);
bool isDbNull = dr.IsDBNull(ordinal);
return isDbNull ? DateTime.MinValue : dr.GetDateTime(ordinal);
}
示例3: getDateTime
protected static DateTime getDateTime(IDataReader dataReader, int column)
{
if (!dataReader.IsDBNull(column))
return dataReader.GetDateTime(column);
return new DateTime();
}
示例4: Select
/// <summary>
/// Mapea un IDataReader a una entidad Proyecto.
/// </summary>
/// <param name="reader">Interfas IDataReader</param>
/// <returns>Proyecto</returns>
public static Proyecto Select(IDataReader reader)
{
return new Proyecto
{
Id = reader.GetInt("CODIGO"),
Nombre = reader.GetString("NOMBRE"),
Descripcion = reader.GetString("DESCRIPCION"),
FechaInicio = reader.GetDateTime("FECHA_INICIO"),
FechaFin = reader.GetDateTime("FECHA_FIN"),
JefeProyecto = new Usuario
{
Id = reader.GetInt("CODIGO_JEFE_PROYECTO")
},
Estado = reader.GetString("ESTADO")
};
}
示例5: CreateRowFromReader
public override Row CreateRowFromReader(IDataReader reader)
{
GetSchemaTable(reader);
Row r = new Row();
for (int i = 0; i < reader.FieldCount; i++)
{
Type fType = reader.GetFieldType(i);
if (fType == typeof(System.Decimal))
{
GetDecimal(reader, r, i);
}
else if (fType == typeof(System.DateTime))
{
object o = reader.GetValue(i);
if (o != DBNull.Value)
{
DateTime dtime = reader.GetDateTime(i);
if (dtime < MinDateTime)
{
o = NullDateTime.Add(new TimeSpan(dtime.Hour, dtime.Minute, dtime.Second));
}
r[reader.GetName(i)] = o;
}
}
else
{
r[reader.GetName(i)] = reader.GetValue(i);
}
}
return r;
}
示例6: GetDateNullCheck
public static string GetDateNullCheck(IDataReader reader, int ordinal, string myFormat = "dd/MM/yyyy HH:mm:ss")
{
try {
return reader.IsDBNull(ordinal) ? "" : reader.GetDateTime(ordinal).ToString(myFormat);
} catch (Exception) {
return "";
}
}
示例7: GetValueByIndex
/// <summary>
/// Gets a column value by the index
/// </summary>
/// <param name="mapping"></param>
/// <param name="dataReader"></param>
/// <returns></returns>
public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
{
if (dataReader.IsDBNull(mapping.ColumnIndex))
{
return DBNull.Value;
}
return dataReader.GetDateTime(mapping.ColumnIndex);
}
示例8: GetValueByName
/// <summary>
///
/// </summary>
/// <param name="mapping"></param>
/// <param name="dataReader"></param>
/// <returns></returns>
public override object GetValueByName(ResultProperty mapping, IDataReader dataReader)
{
int index = dataReader.GetOrdinal(mapping.ColumnName);
if (dataReader.IsDBNull(index))
{
return DBNull.Value;
}
return new DateTime?( dataReader.GetDateTime(index) );
}
示例9: ReadMovie
public static Movie ReadMovie(IDataReader reader)
{
Movie movie = new Movie();
movie.ID = reader.GetInt32(0);
movie.Title = reader.GetString(1);
movie.ReleaseDate = reader.GetDateTime(2).Date;
movie.Genre = reader.GetString(3);
movie.Price = reader.GetDecimal(4);
return movie;
}
示例10: Flight
public Flight(IDataReader reader)
{
ID = reader.GetInt32(reader.GetOrdinal("id"));
location = reader.GetInt32(reader.GetOrdinal("location"));
DateTime start_time = reader.GetDateTime(reader.GetOrdinal("start_time"));
DateTime start_date = reader.GetDateTime(reader.GetOrdinal("start_date"));
start = new DateTime(start_date.Year, start_date.Month, start_date.Day, start_time.Hour, start_time.Minute, start_time.Second);
DateTime end_time = reader.GetDateTime(reader.GetOrdinal("end_time"));
DateTime end_date = reader.GetDateTime(reader.GetOrdinal("end_date"));
end = new DateTime(end_date.Year, end_date.Month, end_date.Day, end_time.Hour, end_time.Minute, end_time.Second);
airplane = reader.GetInt32(reader.GetOrdinal("airplane"));
template = reader.GetInt32(reader.GetOrdinal("template"));
DateTime travelDateTime = reader.GetDateTime(reader.GetOrdinal("travel_time"));
travelTime = new TimeSpan(days: travelDateTime.Day, hours: travelDateTime.Hour, minutes: travelDateTime.Minute, seconds: travelDateTime.Second);
}
示例11: GetConcepts
public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
{
long? relevantConditionConceptId = 0;
DateTime? endDate = null;
if(Concepts.Length == 2)
{
var relevantConcepts = Concepts[1].GetValues(Vocabulary, Concepts[1].Fields[0], reader);
if (relevantConcepts.Count > 0)
relevantConditionConceptId = relevantConcepts.Min(c => c.ConceptId);
}
foreach (var c in base.GetConcepts(concept, reader, keyMaster))
{
var e = (Entity) c;
var calculatedDaysSupply = GetDaysSupply(reader, e);
if (!string.IsNullOrEmpty(EndDate))
{
if (calculatedDaysSupply > 0 && calculatedDaysSupply <= 365)
endDate = e.StartDate.AddDays(calculatedDaysSupply - 1);
else
endDate = reader.GetDateTime(EndDate);
}
var refillString = reader.GetString(Refill);
int? refill = null;
if (!string.IsNullOrEmpty(refillString))
{
int refillValue;
// in Optum Refill looks like: 01, 02...
int.TryParse(refillString, out refillValue);
refill = refillValue;
}
yield return new DrugExposure(e)
{
Id = keyMaster.DrugExposureId,
Refills = refill,
DaysSupply = reader.GetInt(DaysSupply),
CalculatedDaysSupply = calculatedDaysSupply,
Quantity = GetQuantity(reader),
RelevantConditionConceptId = relevantConditionConceptId,
EndDate = endDate == DateTime.MinValue ? null : endDate,
GetEraConceptIdsCall = Vocabulary.LookupIngredientLevel
};
}
}
示例12: Select
/// <summary>
/// Mapea un IDataReader a una entidad Linea Base.
/// </summary>
/// <param name="reader">Interfas IDataReader</param>
/// <returns>LineaBase</returns>
public static LineaBase Select(IDataReader reader)
{
return new LineaBase
{
Id = reader.GetInt("CODIGO"),
Nombre = reader.GetString("NOMBRE"),
Descripcion = reader.GetString("DESCRIPCION"),
ProyectoFase = new ProyectoFase { Id = reader.GetInt("CODIGO_PROYECTO_FASE"), Fase = new Fase { Nombre = reader.GetString("NOMBRE_FASE") } },
Estado = reader.GetString("ESTADO"),
FechaLiberacion = reader.GetDateTime("FECHA_LIBERACION")
};
}
示例13: NullSafeGet
public object NullSafeGet(IDataReader rs, string[] names, object owner)
{
int ordinal = rs.GetOrdinal(names[0]);
if (rs.IsDBNull(ordinal))
{
return DateTime.MinValue;
}
else
{
return rs.GetDateTime(ordinal);
}
}
示例14: CreateLocalViewwwJobFromReader
private LocalViewwwJob CreateLocalViewwwJobFromReader(IDataReader reader)
{
return new LocalViewwwJob
{
RecordId = reader.GetInt32(0),
Creator = reader.GetInt32(1),
Created = reader.GetDateTime(2),
Session = reader.GetInt32(3),
StartTime = reader.GetDateTime(4),
Duration = reader.GetInt32(5),
Customer = reader.GetInt32(6),
Project = reader.GetInt32(7),
ProjectId = reader.GetString(8),
ProjectDescription = reader.GetString(9),
JobType = reader.GetInt32(10),
RateGroup = reader.GetInt32(11),
RateName = reader.GetInt32(12),
Description = reader.GetString(13),
Enabled = reader.GetBoolean(14),
ForceJobsEnabled = reader.GetBoolean(15)
};
}
示例15: GetValue
public override object GetValue(IDataReader reader, int columnIndex)
{
try
{
return reader.GetDateTime(columnIndex);
}
catch (Exception ex)
{
var dateStr = reader.GetString(columnIndex);
Log.Warn("Error reading string as DateTime in Sqlite: " + dateStr, ex);
return DateTime.Parse(dateStr);
}
}