当前位置: 首页>>代码示例>>C#>>正文


C# Schema.CreateQuery方法代码示例

本文整理汇总了C#中Schema.CreateQuery方法的典型用法代码示例。如果您正苦于以下问题:C# Schema.CreateQuery方法的具体用法?C# Schema.CreateQuery怎么用?C# Schema.CreateQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Schema的用法示例。


在下文中一共展示了Schema.CreateQuery方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public override Content.Query.IContentQuery<Content.Models.TextContent> Execute(DataRuleContext dataRuleContext)
        {
            var site = dataRuleContext.Site;
            var repositoryName = site.Repository;
            if (string.IsNullOrEmpty(repositoryName))
            {
                throw new KoobooException("The repository for site is null.");
            }
            var repository = new Repository(repositoryName);
            var schema = new Schema(repository, SchemaName);
            var contentQuery = (IContentQuery<Content.Models.TextContent>)schema.CreateQuery();

            contentQuery.Where(WhereClauses.Parse(schema,dataRuleContext.ValueProvider));

            return contentQuery;
        }
开发者ID:kooboo-jifeng,项目名称:CMS,代码行数:16,代码来源:SchemaDataRule.cs

示例2: Update

        public virtual void Update(Repository repository, Schema schema, string uuid, IEnumerable<string> fieldNames, IEnumerable<object> fieldValues, string userName = "", bool enableVersion = true)
        {
            var content = schema.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault();
            if (content != null)
            {
                var names = fieldNames.ToArray();
                var values = fieldValues.ToArray();
                for (int i = 0; i < names.Length; i++)
                {
                    content[names[i]] = values[i];
                }

                if (!string.IsNullOrEmpty(userName))
                {
                    content.UserId = userName;
                }
                content.___EnableVersion___ = true;
                content.UtcLastModificationDate = DateTime.UtcNow;

                EventBus.Content.ContentEvent.Fire(ContentAction.PreUpdate, content);

                TextContentProvider.Update(content, content);

                EventBus.Content.ContentEvent.Fire(ContentAction.Update, content);

            }
        }
开发者ID:netcowboy,项目名称:CMS,代码行数:27,代码来源:TextContentManager.cs

示例3: UpdateSpecifiedFields

        /// <summary>
        /// Updates the specified field values
        /// </summary>
        /// <param name="repository">The repository.</param>
        /// <param name="schema">The schema.</param>
        /// <param name="uuid">The UUID.</param>
        /// <param name="fieldValues">The field values.</param>
        /// <param name="userName">Name of the user.</param>
        public virtual void UpdateSpecifiedFields(Repository repository, Schema schema, string uuid, NameValueCollection fieldValues, string userName = "", bool enableVersion = true)
        {
            var content = schema.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault();
            if (content != null)
            {

                foreach (var name in fieldValues.AllKeys)
                {
                    content[name] = Binder.ConvertToColumnType(schema, name, fieldValues[name]);
                }

                if (!string.IsNullOrEmpty(userName))
                {
                    content.UserId = userName;
                }
                content.___EnableVersion___ = enableVersion;
                content.UtcLastModificationDate = DateTime.UtcNow;

                EventBus.Content.ContentEvent.Fire(ContentAction.PreUpdate, content);

                TextContentProvider.Update(content, content);

                EventBus.Content.ContentEvent.Fire(ContentAction.Update, content);

            }
        }
开发者ID:netcowboy,项目名称:CMS,代码行数:34,代码来源:TextContentManager.cs

示例4: Delete

        public virtual void Delete(Repository repository, Schema schema, string uuid)
        {
            var textContent = schema.CreateQuery().WhereEquals("UUID", uuid).First();

            EventBus.Content.ContentEvent.Fire(ContentAction.PreDelete, textContent);
            TextContentProvider.Delete(textContent);

            EventBus.Content.ContentEvent.Fire(ContentAction.Delete, textContent);
        }
开发者ID:netcowboy,项目名称:CMS,代码行数:9,代码来源:TextContentManager.cs

示例5: Copy

        public virtual TextContent Copy(Schema schema, string uuid)
        {
            var repository = schema.Repository;
            var content = schema.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault();
            if (content != null)
            {
                var textContent = new TextContent(content);
                textContent.Id = "";
                textContent.UUID = "";
                textContent.UtcCreationDate = DateTime.Now;
                textContent.UtcLastModificationDate = DateTime.Now;
                textContent.Published = null;
                textContent.Sequence = 0;
                textContent.UserKey = null;
                var titleField = schema.AsActual().GetSummarizeColumn();
                if (titleField != null)
                {
                    textContent[titleField.Name] = (content[titleField.Name] ?? "") + " - Copy".Localize();
                }

                EventBus.Content.ContentEvent.Fire(ContentAction.PreAdd, textContent);

                TextContentProvider.Add(textContent);

                var categories = this.QueryCategories(repository, content.FolderName, uuid);
                this.AddCategories(repository, textContent, categories.SelectMany(it => it.Contents).ToArray());

                EventBus.Content.ContentEvent.Fire(ContentAction.Add, textContent);

                return textContent;
            }
            return null;
        }
开发者ID:netcowboy,项目名称:CMS,代码行数:33,代码来源:TextContentManager.cs

示例6: IfUserKeyExists

 protected virtual bool IfUserKeyExists(ContentBase content, string userKey)
 {
     var repository = new Repository(content.Repository);
     if (content is TextContent)
     {
         var textContent = (TextContent)content;
         var schema = new Schema(repository, textContent.SchemaName);
         var contentExists = schema.CreateQuery().WhereEquals("UserKey", userKey).FirstOrDefault();
         if (contentExists != null)
         {
             return contentExists.UUID != content.UUID;
         }
         return false;
     }
     else if (content is MediaContent)
     {
         var mediaContent = (MediaContent)content;
         var folder = new MediaFolder(repository, mediaContent.FolderName);
         var contentExists = folder.CreateQuery().WhereEquals("UserKey", userKey).FirstOrDefault();
         if (contentExists != null)
         {
             return contentExists.UUID != content.UUID;
         }
         return false;
     }
     return false;
 }
开发者ID:jason1234,项目名称:CMS,代码行数:27,代码来源:UserKeyGenerator.cs

示例7: ValidateColumn

        private static void ValidateColumn(Schema schema, TextContent textContent, ref List<RuleViolation> violations, Column column, bool update = false)
        {
            var controlType = Kooboo.CMS.Form.Html.ControlHelper.Resolve(column.ControlType);
            if (controlType != null && controlType.IsFile == true)//ignore the file control type validations.
            {
                return;
            }
            var validations = column.GetValidations();
            foreach (var validation in validations)
            {
                switch (validation.ValidationType)
                {
                    case ValidationType.Required:
                        if (textContent[column.Name] == null || string.IsNullOrEmpty(textContent[column.Name].ToString()))
                        {
                            violations.Add(new RuleViolation(column.Name, null, string.Format(validation.ErrorMessage, column.Name)));
                        }
                        break;
                    case ValidationType.Unique:
                        var value = textContent[column.Name];

                        int hasitems = 0;
                        if ((value == null) || string.IsNullOrEmpty(value.ToString()))
                            hasitems = 1;
                        else
                        {
                            //判断数据是否已经存在
                            if (update == true)
                            {
                                hasitems = schema.CreateQuery().WhereEquals(column.Name, value)
                                                               .WhereNotEquals(Column.UUID.Name, textContent[Column.UUID.Name]).Count();
                            }
                            else
                            {
                                hasitems = schema.CreateQuery().WhereEquals(column.Name, value).Count();
                            }
                        }
                        if (hasitems > 0)
                            violations.Add(new RuleViolation(column.Name, null, string.Format(validation.ErrorMessage, column.Name)));
                        break;
                    case ValidationType.StringLength:
                        var stringLength = (StringLengthValidation)validation;
                        if (column.DataType == DataType.String && textContent[column.Name] != null)
                        {
                            var length = textContent[column.Name].ToString().Length;
                            if (length < stringLength.Min || length > stringLength.Max)
                            {
                                violations.Add(new RuleViolation(column.Name, null, string.Format(validation.ErrorMessage, column.Name)));
                            }

                        }
                        break;
                    case ValidationType.Range:
                        var rangeValidation = (RangeValidation)validation;
                        if (textContent.ContainsKey(column.Name) && textContent[column.Name] != null)
                        {
                            if ((column.DataType == DataType.Int || column.DataType == DataType.Decimal))
                            {
                                decimal decimalValue = Convert.ToDecimal(textContent[column.Name]);

                                decimal start = Convert.ToDecimal(rangeValidation.Start);
                                decimal end = Convert.ToDecimal(rangeValidation.End);

                                if (start > decimalValue || end < decimalValue)
                                {
                                    violations.Add(new RuleViolation(column.Name, null, string.Format(validation.ErrorMessage, column.Name)));
                                }

                            }
                        }
                        break;
                    case ValidationType.Regex:
                        var regexValidation = (RegexValidation)validation;
                        if (textContent.ContainsKey(column.Name) && textContent[column.Name] != null)
                        {
                            string pattern = regexValidation.Pattern;
                            if (!string.IsNullOrEmpty(pattern))
                            {
                                if (!Regex.IsMatch(textContent[column.Name].ToString(), pattern))
                                {
                                    violations.Add(new RuleViolation(column.Name, null, string.Format(validation.ErrorMessage, column.Name)));
                                }
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
        }
开发者ID:RameshGD,项目名称:CMS,代码行数:90,代码来源:TextContentBinder.cs


注:本文中的Schema.CreateQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。