Exemplo n.º 1
0
        public override bool TryResolve(string name, out object value)
        {
            //这里传入的name是字段名,根据字段名找到映射的属性
            FastProperty prop = _mapping.GetMappingProperty(name);

            //如果参数是实体对象,直接返回属性的值
            if (null != prop && _sqlParams.IsObjectParameters() && prop.Info.DeclaringType.IsInstanceOfType(_rawParams))
            {
                value = prop.GetValue(_rawParams);
                return(true);
            }
            //先找字段名
            if (!_sqlParams.TryResolve(name, out value))
            {
                //再找属性名
                if (null != prop && !prop.Name.Equals(name))
                {
                    return(_sqlParams.TryResolve(prop.Name, out value));
                }
                return(false);
            }
            return(true);
        }