예제 #1
0
        protected override void BuildCreateTableColumns()
        {
            IReflector r = Reflector.Bind(_map.EntityType, ReflectorPolicy.CreateInstance(false, false, false, false));

            foreach (var pkInfo in _map.PrimaryKeyMaps)
            {
                BuildColumnBasic(r, pkInfo, true);
                //Note:GUID is not supported
                if (_map.PrimaryKeyGenerate == PrimaryKeyGenerate.Auto)
                {
                    _str.Append("IDENTITY(1, 1) ");
                }
                _str.Append(_tr.Not).Append(_tr.Null).Append(_tr.ColumnDelimiter);
            }

            foreach (var nonPkInfo in _map.NonPKPropertyMaps)
            {
                BuildColumnBasic(r, nonPkInfo, false);
                _str.Append(_tr.ColumnDelimiter);
            }

            _str.Append(_tr.Constraint).Append(_tr.GetEscapedColumnName(PK_PREFIX + _map.Table.LocalName)).Append(_tr.PrimaryKey);
            _str.Append(StringPair.Parenthesis.Begin);
            foreach (var pkInfo in _map.PrimaryKeyMaps)
            {
                _str.Append(_tr.GetEscapedColumnName(pkInfo.ColumnName)).Append(_tr.ColumnDelimiter);
            }
            _str.RemoveEnd(_tr.ColumnDelimiter);
            _str.Append(StringPair.Parenthesis.End);
        }
예제 #2
0
        protected override void BuildCreateTableColumns()
        {
            IReflector r = Reflector.Bind(_map.EntityType, ReflectorPolicy.CreateInstance(false, false, false, false));

            foreach (var pkInfo in _map.PrimaryKeyMaps)
            {
                BuildColumnBasic(r, pkInfo, true);
                if (_map.PrimaryKeyGenerate == PrimaryKeyGenerate.Auto)
                {
                    _str.Append(" AUTO_INCREMENT");
                }
                _str.Append(_tr.ColumnDelimiter);
            }

            foreach (var nonPkInfo in _map.NonPKPropertyMaps)
            {
                BuildColumnBasic(r, nonPkInfo, false);
                _str.Append(_tr.ColumnDelimiter);
            }

            _str.Append(_tr.PrimaryKey);
            _str.Append(StringPair.Parenthesis.Begin);
            foreach (var pkInfo in _map.PrimaryKeyMaps)
            {
                _str.Append(_tr.GetEscapedColumnName(pkInfo.ColumnName)).Append(_tr.ColumnDelimiter);
            }
            _str.RemoveEnd(_tr.ColumnDelimiter);
            _str.Append(StringPair.Parenthesis.End);
        }
예제 #3
0
파일: EvalVisitor.cs 프로젝트: rexzh/RexToy
        public override object Visit(PropertyNode obj)
        {
            object instance = obj.Variable.Accept(this);

            if (instance == null)
            {
                ExceptionHelper.ThrowEvalNull();
            }

            string          propertyName = (obj.Property as SimpleNode).Token.TokenValue;
            IReflector      r;
            ClassDefination cdef = instance as ClassDefination;

            if (cdef != null)
            {
                r = Reflector.Bind(cdef.ObjType, ReflectorPolicy.CreateInstance(false, true, false, false));
            }
            else
            {
                r = Reflector.Bind(instance, ReflectorPolicy.CreateInstance(false, true, false, true));
            }

            if (r.ExistProperty(propertyName))//Note:Property first
            {
                return(r.GetPropertyValue(propertyName));
            }
            else if (r.ExistField(propertyName))//Note:Field 2nd
            {
                return(r.GetFieldValue(propertyName));
            }
            else//Note:Then try indexer
            {
                try
                {
                    return(r.Invoke("get_Item", new object[] { propertyName }));
                }
                catch
                {
                    //Note:Try indexer failed.
                    ExceptionHelper.ThrowIndexOrPropertyNotExist(instance.GetType(), propertyName);
                    return(null);
                }
            }
        }
예제 #4
0
 private EvalSmartInvoker(object obj, bool bindInstance)
     : base(obj, ReflectorPolicy.CreateInstance(false, true, false, bindInstance))
 {
 }