Exemplo n.º 1
0
        public static TodoItem Update(this TodoItem t, DBRecord record)
        {
            t.ID = record.Id;

            t.Name  = record.GetString("Title");
            t.Notes = record.GetString("Description");
            t.Done  = record.GetBoolean("IsDone");
            return(t);
        }
Exemplo n.º 2
0
        public static Dictionary <string, object> ToDictionary(this DBRecord record, DbMapping mapping)
        {
            var dictionary = new Dictionary <string, object>();

            foreach (var fieldName in record.FieldNames())
            {
                var property = mapping.PropertiesInfos.SingleOrDefault(p => p.Name.Equals(fieldName));
                if (property != null)
                {
                    object value = null;
                    var    type  = property.PropertyType;
                    if (type.IsLong())
                    {
                        value = record.GetLong(fieldName);
                    }
                    else if (type.IsNumeric())
                    {
                        value = record.GetDouble(fieldName);
                    }
                    else if (type.IsBool())
                    {
                        value = record.GetBoolean(fieldName);
                    }
                    else if (type.IsDateTime())
                    {
                        var date = record.GetDate(fieldName);
                        value = date.ToDateTime();
                    }
                    else if (type == typeof(string))
                    {
                        value = record.GetString(fieldName);
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                    dictionary.Add(fieldName, value);
                }
            }
            return(dictionary);
        }
		public static TodoItem Update (this TodoItem t, DBRecord record)
		{
			t.ID = record.Id;

			t.Name = record.GetString ("Title");
			t.Notes = record.GetString("Description");
			t.Done = record.GetBoolean ("IsDone");
			return t;
		}