示例#1
0
        public override bool UseWhen()
        {
            // do deep property binding
            if (!(ColumnName.Contains('.')))
            {
                return(false);
            }

            var propertyNames = ColumnName.Split('.');

            if (propertyNames.Count() <= 1)
            {
                throw new Exception(string.Format("Can not find any property represented by deep-binding syntax: \"{0}\"", ColumnName));
            }

            Info = PropertyInfoHelper.GetCaseInsensitivePropertyInfo(TargetType, propertyNames[0]);

            var nextColumnName = string.Join(".", propertyNames.Skip(1).ToList());

            deepAction = ColumnActionFactory.GetAction <ICreatorColumnAction>(Info.PropertyType, nextColumnName);

            if (deepAction == null)
            {
                return(false);
            }

            return(deepAction.UseWhen());
        }
示例#2
0
        protected override void _getSqlCommand(Column column)
        {
            var props    = ColumnName.Split(".".ToCharArray());
            var collName = $"\"{props[0]}\"";

            _getSqlCommandForPostgres(column);
        }
        public string GetStringPropertyName()
        {
            var words = ColumnName.Split(new[] { '-', '_' }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(word => word.Substring(0, 1).ToUpper() +
                                word.Substring(1).ToLower());

            var result = String.Concat(words);

            return(result);
        }
示例#4
0
        private void _getSqlCommandForPostgres(Column column)
        {
            OverrideValueType("like", "text");
            string like = _ignoreCase ? "ILIKE" : "LIKE";

            var props    = ColumnName.Split(".".ToCharArray());
            var collName = $"\"{props[0]}\"";


            var    propertiesList = new List <string>();
            string searchstr      = string.Empty;
            string comm           = String.Empty;

            var jTokenType = column.DotNetType.GetJTokenType();

            switch (jTokenType)
            {
            case JTokenType.Array when jTokenType == JTokenType.Object:
                for (int i = 1; i < props.Length - 1; i++)
                {
                    propertiesList.Add(props[i]);
                }

                if (propertiesList.Any())
                {
                    searchstr = $"->{String.Join("->", propertiesList.Select(s => $"'{s}'"))}";
                }

                searchstr = $"{searchstr}->>'{props.Last()}'::text";


                comm = $"exists (Select 1 from unnest({collName}) as objects where objects{searchstr} {like} @{GetId("like")})";

                SetCommand(comm);
                return;

            case JTokenType.Object:

                if (props.Length == 1)
                {
                    break;
                }

                for (int i = 1; i < props.Length - 1; i++)
                {
                    propertiesList.Add(props[i]);
                }

                if (propertiesList.Any())
                {
                    searchstr = $"->{String.Join("->", propertiesList.Select(s => $"'{s}'"))}";
                }

                searchstr = $"{searchstr}->>'{props.Last()}'::text";

                comm = $"{collName}{searchstr} {like} @{GetId("like")}";


                SetCommand(comm);
                return;
            }

            SetCommand($"{collName}::text {like} @{GetId("like")}");
        }