コード例 #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);
        }
コード例 #2
0
        internal void AddConstraint(EntityField field, object value)
        {
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            // add...
            this.Constraints.Add(new SqlConstraint(field, value));
        }
コード例 #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);
        }
コード例 #4
0
        public String GetStringValue(EntityField field)
        {
            Object value = GetValue(field);

            if (value != null)
            {
                return(value.ToString());
            }
            else
            {
                return(null);
            }
        }
コード例 #5
0
        public bool IsField(string name)
        {
            EntityField field = this.GetField(name, false);

            if (field != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #6
0
        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()));
            }
        }
コード例 #7
0
        public int GetInt32Value(String name)
        {
            EntityField field = EntityType.GetField(name, true);

            return(GetInt32Value(field));
        }
コード例 #8
0
            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);
            }
コード例 #9
0
        public String GetStringValue(String name)
        {
            EntityField field = EntityType.GetField(name, true);

            return(GetStringValue(field));
        }
コード例 #10
0
 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()));
 }
コード例 #11
0
        public Object GetValue(String name)
        {
            EntityField field = EntityType.GetField(name, true);

            return(GetValue(field.Ordinal));
        }
コード例 #12
0
 public Object GetValue(EntityField field)
 {
     return(GetValue(field.Ordinal));
 }
コード例 #13
0
        public void SetValue(EntityField field, Object value, SetReason reason)
        {
            int ordinal = field.Ordinal;

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

            return(GetBooleanValue(field));
        }
コード例 #17
0
 internal SqlConstraint(EntityField field, object value)
 {
     this.Field = field;
     this.Value = value;
 }
コード例 #18
0
 public bool IsModified(EntityField field)
 {
     return IsModified(field.Ordinal);
 }
コード例 #19
0
 public bool IsLoaded(EntityField field)
 {
     return IsLoaded(field.Ordinal);
 }
コード例 #20
0
 public void SetValue(EntityField field, Object value, SetReason reason)
 {
     int ordinal = field.Ordinal;
     SetValue(ordinal, value, reason);
 }
コード例 #21
0
 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()));
 }
コード例 #22
0
        protected void SetValue(String name, Object value, SetReason reason)
        {
            EntityField field = EntityType.GetField(name, true);

            SetValue(field, value, reason);
        }
コード例 #23
0
 public bool IsModified(EntityField field)
 {
     return(IsModified(field.Ordinal));
 }
コード例 #24
0
 public bool IsLoaded(EntityField field)
 {
     return(IsLoaded(field.Ordinal));
 }
コード例 #25
0
 public Object GetValue(EntityField field)
 {
     return GetValue(field.Ordinal);
 }