private Comment MapInstagramComment(InstagramComment reader) { Comment comment = new Comment() { Id = reader.Id, Username = reader.Username, Text = reader.Text, Timestamp = DataReaderUtils.GetDateTime(reader.Timestamp), Likes = DataReaderUtils.GetInt(reader.Like_count) }; return(comment); }
private Post MapInstagramMedia(InstagramMedia reader) { Post post = new Post() { Id = reader.Id, Username = reader.Username, Text = reader.Caption, Timestamp = DataReaderUtils.GetDateTime(reader.Timestamp), Likes = DataReaderUtils.GetInt(reader.Like_count) }; return(post); }
/// <summary> /// Fills the model fromthe result set / data reader. /// It uses the DbAutoFillAttribute to fill the object. /// /// After a call to this method, the model should contain the data properly. /// </summary> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="InvalidOperationException"></exception> /// <exception cref="TypeLoadException"></exception> /// <exception cref="MissingFieldException"></exception> public static void FillObjectFromDataReader <T>(IDataReader dataReader, T obj) where T : new() { if (obj == null) { throw new ArgumentNullException("obj"); } if (dataReader == null) { throw new ArgumentNullException("dataReader"); } Type modelType = obj.GetType(); if (modelType.IsSubclassOf(typeof(IDbAnonymousValue))) { SetDbAnonymousValueFromDataReader(obj as IDbAnonymousValue, dataReader); return; } DbAutoFillAttribute modelAttribute = Attribute.GetCustomAttribute(modelType, typeof(DbAutoFillAttribute)) as DbAutoFillAttribute; if (modelAttribute != null) { if (modelAttribute.FillBehavior == DbFillBehavior.None || modelAttribute.FillBehavior == DbFillBehavior.ToDB) { return; } } PropertyInfo[] modelProperties = modelType.GetProperties(); FieldInfo[] modelFields = modelType.GetFields(); string[] lstDbFields = DataReaderUtils.GetFieldsFromDataReader(dataReader); SetMembersValuesFromDataReader(dataReader, obj, modelProperties, lstDbFields, modelAttribute); SetMembersValuesFromDataReader(dataReader, obj, modelFields, lstDbFields, modelAttribute); }