Exemplo n.º 1
0
        private string GetSnippet(LoadOldItemsInfo info)
        {
            return string.Format(
            @"var updatedIdsList = updatedNew.Select(item => item.ID).ToList();
            var deletedIdsList = deletedIds.Select(item => item.ID).ToList();
            var updatedOld = Filter(Query(), updatedIdsList).Select(item => new {{ item.ID{0} }}).ToList();
            var deletedOld = Filter(Query(), deletedIdsList).Select(item => new {{ item.ID{0} }}).ToList();
            Rhetos.Utilities.Graph.SortByGivenOrder(updatedOld, updatedIdsList, item => item.ID);
            Rhetos.Utilities.Graph.SortByGivenOrder(deletedOld, deletedIdsList, item => item.ID);

            ",
                SelectPropertiesTag.Evaluate(info));
        }
        public IEnumerable <IConceptInfo> CreateNewConcepts(ModificationTimeOfInfo conceptInfo, IDslModel existingConcepts)
        {
            if (!(conceptInfo.Property.DataStructure is EntityInfo))
            {
                throw new DslSyntaxException(conceptInfo, $"{conceptInfo.GetKeywordOrTypeName()} can only be used on an Entity, " +
                                             $"not on {conceptInfo.Property.DataStructure.GetUserDescription()}.");
            }

            var saveMethod = new SaveMethodInfo {
                Entity = (EntityInfo)conceptInfo.Property.DataStructure
            };
            var loadOldItems = new LoadOldItemsInfo {
                SaveMethod = saveMethod
            };

            return(new IConceptInfo[]
            {
                saveMethod,
                loadOldItems,
                new LoadOldItemsTakeInfo {
                    LoadOldItems = loadOldItems, Path = conceptInfo.ModifiedProperty.GetSimplePropertyName()
                }
            });
        }