Exemplo n.º 1
0
        public static void GetFromReader(this SqlQuery query, IDataReader reader, IList <IEntity> into)
        {
            int index = 0;

            foreach (var info in query.GetColumns())
            {
                if (info.IntoField as Field != null && info.IntoRowIndex != -1)
                {
                    var row = into[info.IntoRowIndex];
                    ((Field)info.IntoField).GetFromReader(reader, index, (Row)row);
                }
                else if (info.IntoRowIndex != -1)
                {
                    var row   = (Row)(into[info.IntoRowIndex]);
                    var name  = reader.GetName(index);
                    var field = row.FindField(name) ?? row.FindFieldByPropertyName(name);
                    if (field != null)
                    {
                        //info.IntoField = field;
                        field.GetFromReader(reader, index, row);
                    }
                    else
                    {
                        if (reader.IsDBNull(index))
                        {
                            row.SetDictionaryData(name, null);
                        }
                        else
                        {
                            var value = reader.GetValue(index);
                            row.SetDictionaryData(name, value);
                        }
                    }
                }

                index++;
            }
        }