Exemplo n.º 1
0
        public EntityField AddField(string name, string nativeName, DataType type, int size)
        {
            EntityField field = new EntityField(name, nativeName, type, size, this.Fields.Count);

            this.Fields.Add(field);

            // return...
            return(field);
        }
Exemplo n.º 2
0
        internal void AddConstraint(EntityField field, object value)
        {
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            // add...
            this.Constraints.Add(new SqlConstraint(field, value));
        }
Exemplo n.º 3
0
        internal void AddConstraint(string name, object value)
        {
            EntityField field = this.Box.EntityType.GetField(name, true);

            if (field == null)
            {
                throw new InvalidOperationException("'field' is null.");
            }

            // defer...
            AddConstraint(field, value);
        }
        public String GetStringValue(EntityField field)
        {
            Object value = GetValue(field);

            if (value != null)
            {
                return(value.ToString());
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        public bool IsField(string name)
        {
            EntityField field = this.GetField(name, false);

            if (field != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public int GetInt32Value(EntityField field)
        {
            Object value = GetValue(field);

            if (value == null)
            {
                return(0);
            }
            else if (value is Int32)
            {
                return((int)value);
            }
            else
            {
                throw new Exception(string.Format("Cannot handle '%s'.", value.GetType()));
            }
        }
        public int GetInt32Value(String name)
        {
            EntityField field = EntityType.GetField(name, true);

            return(GetInt32Value(field));
        }
            protected List <T> LoadEntities(XDocument doc, EntityType et)
            {
                // feed...
                XElement feed = doc.Element(XName.Get("feed", AtomNamespace));

                if (feed == null)
                {
                    throw new InvalidOperationException("'feedElement' is null.");
                }

                // walk...
                List <T> results = et.CreateCollectionInstance <T>();
                var      entries = feed.Elements(XName.Get("entry", AtomNamespace));

                foreach (XElement entry in entries)
                {
                    // get the content item...
                    XElement content = entry.Element(XName.Get("content", AtomNamespace));
                    if (content == null)
                    {
                        throw new InvalidOperationException("'content' is null.");
                    }

                    // then get the properties element...
                    XElement properties = content.Element(XName.Get("properties", MsMetadataNamespace));
                    if (properties == null)
                    {
                        throw new InvalidOperationException("'properties' is null.");
                    }

                    // create an item...
                    T item = (T)et.CreateInstance();
                    if (item == null)
                    {
                        throw new InvalidOperationException("'item' is null.");
                    }

                    // then get the fields...
                    Dictionary <string, object> values = new Dictionary <string, object>();
                    foreach (XElement fieldElement in properties.Elements())
                    {
                        if (fieldElement.Name.Namespace == MsDataNamespace)
                        {
                            // do we have that field?
                            EntityField field = et.GetField(fieldElement.Name.LocalName, false);
                            if (field != null)
                            {
                                // get the value...
                                object value = this.GetValue(fieldElement);
                                item.SetValue(field, value, SetReason.UserSet);
                            }
                        }
                    }

                    // add...
                    results.Add(item);
                }

                // return...
                return(results);
            }
        public String GetStringValue(String name)
        {
            EntityField field = EntityType.GetField(name, true);

            return(GetStringValue(field));
        }
 public int GetInt32Value(EntityField field)
 {
     Object value = GetValue(field);
     if (value == null)
         return 0;
     else if (value is Int32)
         return (int)value;
     else
         throw new Exception(string.Format("Cannot handle '%s'.", value.GetType()));
 }
        public Object GetValue(String name)
        {
            EntityField field = EntityType.GetField(name, true);

            return(GetValue(field.Ordinal));
        }
 public Object GetValue(EntityField field)
 {
     return(GetValue(field.Ordinal));
 }
        public void SetValue(EntityField field, Object value, SetReason reason)
        {
            int ordinal = field.Ordinal;

            SetValue(ordinal, value, reason);
        }
 public String GetStringValue(EntityField field)
 {
     Object value = GetValue(field);
     if (value != null)
         return value.ToString();
     else
         return null;
 }
 internal SqlConstraint(EntityField field, object value)
 {
     this.Field = field;
     this.Value = value;
 }
        public bool GetBooleanValue(String name)
        {
            EntityField field = EntityType.GetField(name, true);

            return(GetBooleanValue(field));
        }
 internal SqlConstraint(EntityField field, object value)
 {
     this.Field = field;
     this.Value = value;
 }
 public bool IsModified(EntityField field)
 {
     return IsModified(field.Ordinal);
 }
 public bool IsLoaded(EntityField field)
 {
     return IsLoaded(field.Ordinal);
 }
 public void SetValue(EntityField field, Object value, SetReason reason)
 {
     int ordinal = field.Ordinal;
     SetValue(ordinal, value, reason);
 }
 public bool GetBooleanValue(EntityField field)
 {
     Object value = GetValue(field);
     if (value == null)
         return false;
     else if (value is bool)
         return (bool)value;
     else if (value is int)
     {
         int asInt = (int)value;
         if (asInt == 0)
             return false;
         else
             return true;
     }
     else
         throw new Exception(string.Format("Cannot handle '{0}'.", value.GetType()));
 }
        protected void SetValue(String name, Object value, SetReason reason)
        {
            EntityField field = EntityType.GetField(name, true);

            SetValue(field, value, reason);
        }
 public bool IsModified(EntityField field)
 {
     return(IsModified(field.Ordinal));
 }
 public bool IsLoaded(EntityField field)
 {
     return(IsLoaded(field.Ordinal));
 }
 public Object GetValue(EntityField field)
 {
     return GetValue(field.Ordinal);
 }