Пример #1
0
        public static DynamicSql SqlProjectFields(
            this DynamicSql query, ConfigQueryProjection model)
        {
            query = DynamicSql.DeepClone(query);
            var finalFields = model.GetFieldsArr()
                              .Where(f => ConfigQueryProjection.Projections.ContainsKey(f))
                              .Select(f => ConfigQueryProjection.Projections[f]);

            if (finalFields.Any())
            {
                var projectionClause = string.Join(',', finalFields);
                query.DynamicForm = query.DynamicForm
                                    .Replace(DynamicSql.PROJECTION, projectionClause);
            }
            var finalResults = model.GetFieldsArr()
                               .Where(f => ConfigQueryProjection.Results.ContainsKey(f))
                               .Select(f => ConfigQueryProjection.Results[f]);

            query.MultiResults.AddRange(finalResults);
            return(query);
        }
Пример #2
0
        public static DynamicSql SqlJoin(
            this DynamicSql query, ConfigQueryProjection model)
        {
            query = DynamicSql.DeepClone(query);
            var joins = model.GetFieldsArr()
                        .Where(f => ConfigQueryProjection.Joins.ContainsKey(f))
                        .Select(f => ConfigQueryProjection.Joins[f]);

            if (joins.Any())
            {
                var joinClause = string.Join('\n', joins);
                query.DynamicForm = query.DynamicForm
                                    .Replace(DynamicSql.JOIN, joinClause);
            }
            return(query);
        }
Пример #3
0
        public IDictionary <string, object> GetConfigDynamic(
            ConfigQueryRow row, ConfigQueryProjection projection,
            ConfigQueryOptions options)
        {
            var obj = new Dictionary <string, object>();

            foreach (var f in projection.GetFieldsArr())
            {
                switch (f)
                {
                case ConfigQueryProjection.INFO:
                {
                    var entity = row.Config;
                    obj["id"]          = entity.Id;
                    obj["code"]        = entity.Code;
                    obj["name"]        = entity.Name;
                    obj["description"] = entity.Description;
                    obj["location_id"] = entity.LocationId;
                }
                break;

                case ConfigQueryProjection.SELECT:
                {
                    var entity = row.Config;
                    obj["id"]   = entity.Id;
                    obj["code"] = entity.Code;
                    obj["name"] = entity.Name;
                }
                break;

                case ConfigQueryProjection.DETAIL:
                {
                    var entity   = row.Config;
                    var playlist = GetScreenSaverPlaylist(entity);
                    var home     = GetHomePageConfig(entity);
                    var peConfig = GetProgramEventConfig(entity);
                    var cConfig  = GetContactConfig(entity);
                    obj["screen_saver_playlist"] = playlist;
                    obj["home_config"]           = home;
                    obj["program_event_config"]  = peConfig;
                    obj["contact_config"]        = cConfig;
                }
                break;
                }
            }
            return(obj);
        }