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


C# IClassMap.GetSourceMap方法代码示例

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


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

示例1: CreateTableForClass

 protected virtual void CreateTableForClass(IClassMap classMap, IDomainMap targetDomainMap, bool generateMappings)
 {
     ITableMap tableMap = null;
     ISourceMap addToSourceMap = null;
     IClassMap classMapClone = null;
     string name = "";
     ISourceMap sourceMap = classMap.GetSourceMap();
     if (sourceMap == null)
     {
         sourceMap = classMap.DomainMap.GetSourceMap();
         if (sourceMap == null)
         {
             throw new Exception("No default data source specified for domain model! Can't add table for class!");
         }
     }
     addToSourceMap = targetDomainMap.GetSourceMap(sourceMap.Name);
     if (addToSourceMap == null)
     {
         addToSourceMap = (ISourceMap) sourceMap.Clone();
         addToSourceMap.DomainMap = targetDomainMap;
     }
     if (classMap.Table.Length > 0)
     {
         name = classMap.Table;
     }
     else
     {
         name = GetTableNameForClass(classMap);
     }
     tableMap = addToSourceMap.GetTableMap(name);
     if (tableMap == null)
     {
         tableMap = new TableMap();
         tableMap.Name = name;
         tableMap.SourceMap = addToSourceMap;
     }
     if (generateMappings & classMap.Table.Length < 1)
     {
         classMapClone = targetDomainMap.GetClassMap(classMap.Name);
         if (classMapClone == null)
         {
             classMapClone = (IClassMap) classMap.Clone();
             classMapClone.DomainMap = targetDomainMap;
         }
         classMapClone.Table = tableMap.Name;
         if (!(addToSourceMap.Name == targetDomainMap.Source))
         {
             classMapClone.Source = addToSourceMap.Name;
         }
         classMapClone.DomainMap = targetDomainMap;
     }
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:52,代码来源:ClassesToTablesTransformer.cs

示例2: CreateTypeColumnForClass

 protected virtual void CreateTypeColumnForClass(IClassMap classMap, IDomainMap targetDomainMap, bool generateMappings)
 {
     ITableMap tableMap = null;
     ISourceMap sourceMap = null;
     ISourceMap addToSourceMap = null;
     IClassMap classMapClone = null;
     IColumnMap columnMap = null;
     string tableName = "";
     string name = "";
     sourceMap = classMap.GetSourceMap();
     if (sourceMap == null)
     {
         sourceMap = classMap.DomainMap.GetSourceMap();
         if (sourceMap == null)
         {
             throw new Exception("No default data source specified for domain model! Can't add table for class!");
         }
     }
     addToSourceMap = targetDomainMap.GetSourceMap(sourceMap.Name);
     if (addToSourceMap == null)
     {
         addToSourceMap = (ISourceMap) sourceMap.Clone();
         addToSourceMap.DomainMap = targetDomainMap;
     }
     if (classMap.Table.Length > 0)
     {
         tableName = classMap.Table;
     }
     else
     {
         tableName = GetTableNameForClass(classMap);
     }
     tableMap = addToSourceMap.GetTableMap(tableName);
     if (tableMap == null)
     {
         tableMap = new TableMap();
         tableMap.Name = tableName;
         tableMap.SourceMap = addToSourceMap;
     }
     if (classMap.TypeColumn.Length > 0)
     {
         name = classMap.TypeColumn;
     }
     else
     {
         name = GetTypeColumnNameForClass(classMap);
     }
     columnMap = tableMap.GetColumnMap(name);
     if (columnMap == null)
     {
         columnMap = new ColumnMap();
         columnMap.Name = name;
         columnMap.TableMap = tableMap;
     }
     columnMap.DataType = DbType.AnsiStringFixedLength;
     columnMap.Length = 1;
     columnMap.Precision = 1;
     columnMap.Scale = 0;
     columnMap.IsPrimaryKey = true;
     columnMap.AllowNulls = false;
     if (generateMappings & classMap.TypeColumn.Length < 1)
     {
         classMapClone = targetDomainMap.GetClassMap(classMap.Name);
         if (classMapClone == null)
         {
             classMapClone = (IClassMap) classMap.Clone();
             classMapClone.DomainMap = targetDomainMap;
         }
         classMapClone.TypeColumn = name;
     }
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:71,代码来源:ClassesToTablesTransformer.cs

示例3: EnsureConsistency

        private void EnsureConsistency(Type type, IClassMap classMap)
        {
            IContext ctx = this.Context;

            if (ctx.ReadConsistency.Equals(ConsistencyMode.Pessimistic) || ctx.WriteConsistency.Equals(ConsistencyMode.Pessimistic))
            {
                ISourceMap sourceMap = classMap.GetSourceMap();
                if (sourceMap != null)
                {
                    if (sourceMap.PersistenceType.Equals(PersistenceType.ObjectRelational) || sourceMap.PersistenceType.Equals(PersistenceType.Default))
                    {
                        ITransaction tx = ctx.GetTransaction(ctx.GetDataSource(sourceMap).GetConnection());
                        if (tx == null)
                        {
                            if (ctx.WriteConsistency.Equals(ConsistencyMode.Pessimistic))
                            {
                                throw new WriteConsistencyException(
                                    string.Format("A write consistency exception has occurred. An object of type {0} was created outside of a transaction. This is not permitted in a context using Pessimistic WriteConsistency.",
                                    type),
                                    null);
                            }
                            throw new ReadConsistencyException(
                                string.Format("A read consistency exception has occurred. An object of type {0} was created outside of a transaction. This is not permitted in a context using Pessimistic ReadConsistency.",
                                type),
                                null);
                        }
                    }
                }
            }
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:30,代码来源:AssemblyManager.cs


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