當前位置: 首頁>>代碼示例>>C#>>正文


C# SqlQuery.Select方法代碼示例

本文整理匯總了C#中Serenity.Data.SqlQuery.Select方法的典型用法代碼示例。如果您正苦於以下問題:C# SqlQuery.Select方法的具體用法?C# SqlQuery.Select怎麽用?C# SqlQuery.Select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Serenity.Data.SqlQuery的用法示例。


在下文中一共展示了SqlQuery.Select方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnPrepareQuery

        public override void OnPrepareQuery(ISaveRequestHandler handler, SqlQuery query)
        {
            base.OnPrepareQuery(handler, query);

            if (this.replaceFields != null)
            {
                foreach (var field in replaceFields.Values)
                {
                    if (!field.IsTableField() &&
                        (!(query is ISqlQueryExtensible) ||
                          ((ISqlQueryExtensible)query).GetSelectIntoIndex(field) <= 0))
                        query.Select(field);
                }
            }
        }
開發者ID:volkanceylan,項目名稱:Serenity,代碼行數:15,代碼來源:MultipleImageUploadBehavior.cs

示例2: ProcessReplaceFields

        internal static string ProcessReplaceFields(string s, Dictionary<string, Field> replaceFields, ISaveRequestHandler handler)
        {
            if (replaceFields == null)
                return s;

            var row = handler.Row;

            // foreign / calculated fields might not be available yet in new row
            // so load them from database 

            // TODO: if referenced foreign fields changed on update, 
            // values might be wrong in before update where we set filename
            // so need to handle update in AfterSave just like create

            if (handler.IsCreate &&
                replaceFields.Values.Any(x => !x.IsTableField()))
            {
                var idField = (Field)(((IIdRow)handler.Row).IdField);

                row = handler.Row.Clone();
                var query = new SqlQuery()
                    .From(row);

                foreach (var field in replaceFields.Values)
                    query.Select(field);

                query.Where(idField == new ValueCriteria(idField.AsObject(row)));

                query.GetFirst(handler.Connection);
            }

            foreach (var p in replaceFields)
            {
                var val = p.Value.AsObject(row);
                string str;

                var colon = p.Key.IndexOf(":");
                if (colon >= 0)
                    str = String.Format("{0:" + p.Key.Substring(colon + 1, p.Key.Length - colon - 2) + "}", val);
                else
                    str = Convert.ToString(val ?? "", CultureInfo.InvariantCulture);

                str = StringHelper.SanitizeFilename(str).Replace('\\', '_').Replace("..", "_");
                if (string.IsNullOrWhiteSpace(str))
                    str = "_";

                while (str.EndsWith("."))
                    str = str.Substring(0, str.Length - 1) + "_";

                s = s.Replace(p.Key, str);
            }

            while (s.IndexOf("//") > 0)
                s = s.Replace("//", "/_/");

            return s;
        }
開發者ID:volkanceylan,項目名稱:Serenity,代碼行數:57,代碼來源:ImageUploadBehavior.cs


注:本文中的Serenity.Data.SqlQuery.Select方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。