本文整理汇总了C#中System.Data.DataRow.StringOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# DataRow.StringOrDefault方法的具体用法?C# DataRow.StringOrDefault怎么用?C# DataRow.StringOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataRow
的用法示例。
在下文中一共展示了DataRow.StringOrDefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _initfromRow
private void _initfromRow(DataRow dr)
{
FrameId = dr.IntOrZero("FrameId");
PanelId = dr.IntOrZero("PanelId");
Duration = dr.IntOrDefault("Duration", 60);
Sort = dr.IntOrZero("Sort");
BeginsOn = dr["BeginsOn"] == DBNull.Value ? null : (DateTime?)dr["BeginsOn"];
EndsOn = dr["EndsOn"] == DBNull.Value ? null : (DateTime?)dr["EndsOn"];
DateCreated = dr["DateCreated"] == DBNull.Value ? null : (DateTime?)dr["DateCreated"];
TemplateName = dr.StringOrDefault("TemplateName", "default");
Html = dr.StringOrBlank("Html");
FrameType = (FrameTypes)dr.IntOrZero("FrameType");
CacheInterval = dr.IntOrZero("CacheInterval");
CacheInterval = CacheInterval < 0 ? 0 : CacheInterval;
Version = BitConverter.ToUInt64((byte[])dr["Version"], 0); // is never a null
}
示例2: _initFromRow
private void _initFromRow(DataRow r)
{
this.LocationId = r.IntOrZero("LocationId");
this.LevelId = r.IntOrZero("LevelId");
this.TemperatureUnit = r.StringOrDefault("TemperatureUnit", "C").ToLower();
this.DateFormat = r.StringOrDefault("DateFormat", "LL");
this.TimeFormat = r.StringOrDefault("TimeFormat", "LT");
this.Name = r.StringOrBlank("Name");
if (this.Name == "")
this.Name = string.Format("Location {0}", this.LocationId);
this.TimeZone = TimeZoneInfo.FindSystemTimeZoneById(
r.StringOrDefault("TimeZone", ServerGeoData.TimeZone.Id)
);
double? latitude = r["Latitude"] as Nullable<double>;
if (latitude != null)
this.Latitude = latitude.Value;
else
this.Latitude = ServerGeoData.Latitude;
double? longitude = r["Longitude"] as Nullable<double>;
if (longitude != null)
this.Longitude = longitude.Value;
else
this.Longitude = ServerGeoData.Longitude;
int? woeid = r["Woeid"] as Nullable<int>;
this.Woeid = woeid ?? 0;
this.Culture = r.StringOrBlank("Culture");
}