Пример #1
0
        private void CreateContext()
        {
            lock (_staticLock)
            {
                if (_typeToTableMap.ContainsKey(_classType))
                {
                    _tableName = _typeToTableMap[_classType];
                    _context   = _typeToContextMap[_classType];
                }
                else
                {
                    MapToAttribute mapToAttribute = ClassType.GetAttribute <MapToAttribute>(true);
                    DefaultSortExpressionAttribute sortAttribute = ClassType.GetAttribute <DefaultSortExpressionAttribute>(true);

                    if (mapToAttribute == null)
                    {
                        throw new CSException(string.Format("No MapTo() attribute defined for class {0}", ClassType.Name));
                    }

                    _tableName = mapToAttribute.Name;
                    _context   = mapToAttribute.Context;

                    if (sortAttribute != null)
                    {
                        _defaultSortExpression = sortAttribute.Expression;
                    }
                }
            }

            if (_context == null)
            {
                _context = CSConfig.DEFAULT_CONTEXTNAME;
            }
        }