/// <summary> /// Instantiate the object from a DataRow. /// </summary> /// <param name="row">DataRow.</param> /// <returns>ObjectMetadata.</returns> public static ObjectMetadata FromDataRow(DataRow row) { if (row == null) { throw new ArgumentNullException(nameof(row)); } ObjectMetadata ret = new ObjectMetadata(); if (row["Id"] != null && row["Id"] != DBNull.Value) { ret.Id = Convert.ToInt64(row["Id"]); } if (row["ObjectKey"] != null && row["ObjectKey"] != DBNull.Value) { ret.ObjectKey = row["ObjectKey"].ToString(); } if (row["GUID"] != null && row["GUID"] != DBNull.Value) { ret.GUID = row["GUID"].ToString(); } if (row["ContentType"] != null && row["ContentType"] != DBNull.Value) { ret.ContentType = row["ContentType"].ToString(); } if (row["ContentLength"] != null && row["ContentLength"] != DBNull.Value) { ret.ContentLength = Convert.ToInt64(row["ContentLength"]); } if (row["Md5"] != null && row["Md5"] != DBNull.Value) { ret.Md5 = row["Md5"].ToString(); } if (row["Tags"] != null && row["Tags"] != DBNull.Value) { ret.Tags = Common.CsvToStringList(row["Tags"].ToString()); } if (row["CreatedUtc"] != null && row["CreatedUtc"] != DBNull.Value) { ret.CreatedUtc = Convert.ToDateTime(row["CreatedUtc"]); } if (row["LastUpdateUtc"] != null && row["LastUpdateUtc"] != DBNull.Value) { ret.LastUpdateUtc = Convert.ToDateTime(row["LastUpdateUtc"]); } if (row["LastAccessUtc"] != null && row["LastAccessUtc"] != DBNull.Value) { ret.LastAccessUtc = Convert.ToDateTime(row["LastAccessUtc"]); } return(ret); }