Example #1
0
        public static async Task AutoMergePatterns()
        {
            var storept = new PatternDataStore();
            var lst     = await storept.GetDataByLang(2);

            var dic = lst.GroupBy(o => o.PATTERN).Where(g => g.Count() > 1).ToDictionary(g => g.Key, g => g.OrderBy(o => o.ID).ToList());

            foreach (var kv in dic)
            {
                var sourceItems = kv.Value;
                var mergedItem  = new MPattern
                {
                    IDS_MERGE = string.Join(",", sourceItems.Select(o => o.ID.ToString())),
                    PATTERN   = kv.Key,
                    NOTE      = sourceItems.Select(o => o.NOTE).SplitUsingCommaAndMerge(),
                    TAGS      = sourceItems.Select(o => o.TAGS).SplitUsingCommaAndMerge()
                };
                await storept.MergePatterns(mergedItem);
            }
        }