コード例 #1
0
        public long?Insert(string tableName, DictionaryItem data)
        {
            var objClass = Schema.FindClassByID(tableName);

            if (objClass == null)
            {
                if (Schema.FindRelationshipByID(tableName) != null)
                {
                    StorageDalc.Insert(tableName, (System.Collections.IDictionary)data.Data);
                    return(null);
                }
                throw new Exception(String.Format("Unknown table {0}", tableName));
            }
            var objContainer = new ObjectContainer(objClass);

            foreach (var entry in data.Data)
            {
                var prop = objClass.FindPropertyByID(entry.Key);
                if (prop != null && !prop.PrimaryKey)
                {
                    objContainer[entry.Key] = entry.Value;
                }
            }
            ObjStorage.Insert(objContainer);
            return(objContainer.ID);
        }