当前位置: 首页>>代码示例>>C#>>正文


C# Connection.IsDBNull方法代码示例

本文整理汇总了C#中Connection.IsDBNull方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.IsDBNull方法的具体用法?C# Connection.IsDBNull怎么用?C# Connection.IsDBNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connection的用法示例。


在下文中一共展示了Connection.IsDBNull方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetValue

 internal object GetValue(int i,Connection conn){
     if (IsDBNull(i,conn))
         return null;
     if (_tableFieldCounts.ContainsKey(i))
     {
         Table t = (Table)LazyProxy.Instance(_tableFields[_fieldNames[i]].GetConstructor(System.Type.EmptyTypes).Invoke(new object[0]));
         sTableField[] flds = conn.Pool.Mapping[_tableFields[_fieldNames[i]]].Fields;
         int index = 0;
         i = TranslateFieldIndex(i);
         foreach (sTableField fld in flds)
         {
             PropertyInfo pi = t.GetType().GetProperty(fld.ClassProperty, Utility._BINDING_FLAGS_WITH_INHERITANCE);
             if (!pi.PropertyType.IsArray || !pi.PropertyType.Equals(typeof(byte[])))
             {
                 if (conn.Pool.Mapping.IsMappableType(pi.PropertyType) && !Utility.IsEnum(pi.PropertyType))
                 {
                     if (!conn.IsDBNull(i + index))
                     {
                         if (t.GetField(pi.Name) == null)
                         {
                             Table tmp = (Table)LazyProxy.Instance(pi.PropertyType.GetConstructor(Type.EmptyTypes).Invoke(new object[0]));
                             tmp.LoadStatus = LoadStatus.Partial;
                             t.SetField(fld.Name, tmp);
                         }
                         Table tbl = (Table)t.GetField(pi.Name);
                         foreach (sTableField f in conn.Pool.Mapping[tbl.GetType()].Fields)
                         {
                             if (fld.ExternalField == f.Name)
                             {
                                 t.RecurSetPropertyValue(f.Name, conn, conn.GetName(i + index), tbl);
                                 index++;
                                 break;
                             }
                         }
                     }
                     else
                         index++;
                 }
                 else
                 {
                     if (!conn.IsDBNull(i + index))
                     {
                         if (Utility.IsEnum(pi.PropertyType))
                             t.SetField(fld.ClassProperty, conn.Pool.GetEnumValue(pi.PropertyType, conn.GetInt32(i + index)));
                         else
                             t.SetField(fld.ClassProperty, conn[i + index]);
                     }
                     index++;
                 }
             }
         }
         t.LoadStatus = LoadStatus.Complete;
         return t;
     }
     else if (_enumFields.ContainsKey(i))
     {
         return _pool.GetEnumValue(_enumFields[i], conn.GetInt32(TranslateFieldIndex(i)));
     }else
         return conn.GetValue(TranslateFieldIndex(i));
 }
开发者ID:marquismark,项目名称:dbpro-orm,代码行数:60,代码来源:ClassQuery.cs

示例2: IsDBNull

 internal bool IsDBNull(int i,Connection conn)
 {
     if (!_tableFieldCounts.ContainsKey(i))
         return conn.IsDBNull(TranslateFieldIndex(i));
     else
     {
         int start = TranslateFieldIndex(i);
         for (int x = 0; x < _tableFieldCounts[i]; x++)
         {
             if (!conn.IsDBNull(x + start))
                 return false;
         }
         return true;
     }
 }
开发者ID:marquismark,项目名称:dbpro-orm,代码行数:15,代码来源:ClassQuery.cs

示例3: Init

 public void Init(Connection conn)
 {
     _tables = new List<ExtractedTableMap>();
     _triggers = new List<Trigger>();
     _generators = new List<Generator>();
     _identities = new List<IdentityField>();
     _views = new List<View>();
     _procedures = new List<StoredProcedure>();
     _createdTypes = new List<Type>();
     conn.ExecuteQuery(conn.Pool.queryBuilder.SelectTriggers());
     while (conn.Read())
     {
         //patch to handle long trigger code from mssql
         if (_triggers.Count > 0)
         {
             if (_triggers[_triggers.Count - 1].Name == (string)conn[0])
                 _triggers[_triggers.Count - 1] = new Trigger((string)conn[0], (string)conn[1], _triggers[_triggers.Count - 1].Code + (string)conn[2]);
             else
                 _triggers.Add(new Trigger((string)conn[0], (string)conn[1], (string)conn[2]));
         }else
             _triggers.Add(new Trigger((string)conn[0], (string)conn[1], (string)conn[2]));
     }
     conn.Close();
     conn.ExecuteQuery(conn.Pool.queryBuilder.SelectProcedures());
     while (conn.Read())
     {
         _procedures.Add(new StoredProcedure(conn[0].ToString(), conn[1].ToString(), conn[2].ToString(), conn[3].ToString(), conn[4].ToString()));
     }
     conn.Close();
     conn.ExecuteQuery(conn.queryBuilder.SelectViews());
     while (conn.Read())
         _views.Add(new View((string)conn[0], (string)conn[1]));
     conn.Close();
     conn.ExecuteQuery(conn.queryBuilder.SelectTableNames());
     while (conn.Read())
     {
         _tables.Add(new ExtractedTableMap((string)conn[0]));
     }
     conn.Close();
     for (int x = 0; x < _tables.Count; x++)
     {
         ExtractedTableMap etm = _tables[x];
         etm.Indices = conn.queryBuilder.ExtractTableIndexes(etm.TableName, conn);
         conn.ExecuteQuery(conn.queryBuilder.SelectTableFields(etm.TableName));
         while (conn.Read())
         {
             etm.Fields.Add(new ExtractedFieldMap(conn[0].ToString(), conn[1].ToString(),
                                                  long.Parse(conn[2].ToString()), bool.Parse(conn[3].ToString()), bool.Parse(conn[4].ToString()),
                                                  bool.Parse(conn[5].ToString()),
                                                  (conn.IsDBNull(6) ? null : conn[6].ToString())));
         }
         conn.Close();
         conn.ExecuteQuery(conn.queryBuilder.SelectForeignKeys(etm.TableName));
         while (conn.Read())
         {
             etm.ForeignFields.Add(new ForeignRelationMap(conn[5].ToString(), conn[0].ToString(), conn[1].ToString(),
                                                          conn[2].ToString(), conn[3].ToString(), conn[4].ToString()));
         }
         conn.Close();
         _tables.RemoveAt(x);
         _tables.Insert(x, etm);
     }
     if (conn.UsesGenerators)
     {
         conn.ExecuteQuery(conn.queryBuilder.SelectGenerators());
         while (conn.Read())
         {
             _generators.Add(new Generator((string)conn[0]));
         }
         conn.Close();
         for (int x = 0; x < _generators.Count; x++)
         {
             Generator gen = _generators[x];
             conn.ExecuteQuery(conn.queryBuilder.GetGeneratorValue(gen.Name));
             conn.Read();
             gen.Value = long.Parse(conn[0].ToString());
             conn.Close();
             _generators.RemoveAt(x);
             _generators.Insert(x, gen);
         }
     }
     if (conn.UsesIdentities)
     {
         conn.ExecuteQuery(conn.queryBuilder.SelectIdentities());
         while (conn.Read())
         {
             _identities.Add(new IdentityField((string)conn[0], (string)conn[1], (string)conn[2], (string)conn[3]));
         }
         conn.Close();
     }
 }
开发者ID:marquismark,项目名称:dbpro-orm,代码行数:91,代码来源:StructureUpdater.cs


注:本文中的Connection.IsDBNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。