新增读取文档帮助
@@ -17,7 +17,8 @@ namespace FreeSql.Site.DAL
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public virtual long Insert(T model)
 | 
			
		||||
        {
 | 
			
		||||
            return DataBaseType.MySql.DB().Insert<T>(model).ExecuteIdentity();
 | 
			
		||||
            var runsql = DataBaseType.MySql.DB().Insert<T>(model);
 | 
			
		||||
            return runsql.ExecuteIdentity();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
@@ -72,7 +73,7 @@ namespace FreeSql.Site.DAL
 | 
			
		||||
            var count = list.Count();
 | 
			
		||||
            //设置分页操作
 | 
			
		||||
            if (pageInfo != null && pageInfo.IsPaging)
 | 
			
		||||
                list.Skip(pageInfo.PageIndex * pageInfo.PageSize).Limit(pageInfo.PageSize);
 | 
			
		||||
                list.Skip((pageInfo.PageIndex - 1) * pageInfo.PageSize).Limit(pageInfo.PageSize);
 | 
			
		||||
 | 
			
		||||
            //执行查询
 | 
			
		||||
            return (list.ToList(), count);
 | 
			
		||||
 
 | 
			
		||||
@@ -7,16 +7,16 @@ namespace FreeSql.Site.Entity
 | 
			
		||||
    public class BaseEntity
 | 
			
		||||
    {
 | 
			
		||||
        [Column(IsIdentity = true, IsPrimary = true)]
 | 
			
		||||
        public int ID { get; set; }
 | 
			
		||||
        public int ID { get; set; } = 0;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 状态
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int Status { get; set; }
 | 
			
		||||
        public int Status { get; set; } = 1;
 | 
			
		||||
 | 
			
		||||
        public DateTime? CreateDt { get; set; }
 | 
			
		||||
        public DateTime? CreateDt { get; set; } = DateTime.Now;
 | 
			
		||||
 | 
			
		||||
        public string CreateBy { get; set; }
 | 
			
		||||
        public string CreateBy { get; set; } = "admin";
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,6 +24,21 @@ namespace FreeSql.Site.Entity
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string DocAbstract { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 内容来源类型(0 当前记录 1=Url地址
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int OriginType { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 来源地址
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string OriginUrl { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 编辑器模式 (=0 Markdown =1 HTML编辑器 )
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int EditorMode { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 文档内容
 | 
			
		||||
        /// </summary>
 | 
			
		||||
 
 | 
			
		||||
@@ -60,7 +60,8 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers
 | 
			
		||||
                if (!string.IsNullOrEmpty(model.DocTitle))
 | 
			
		||||
                    searchPredicate = searchPredicate.And(u => u.DocTitle.IndexOf(model.DocTitle) != -1);
 | 
			
		||||
            }
 | 
			
		||||
            var contents = DocumentContentDAL.Query(searchPredicate);
 | 
			
		||||
            PageInfo pageinfo = new PageInfo() { IsPaging = true, PageIndex = page, PageSize = limit };
 | 
			
		||||
            var contents = DocumentContentDAL.Query(searchPredicate, null, pageinfo);
 | 
			
		||||
 | 
			
		||||
            return Json(new DataPage<DocumentContent>
 | 
			
		||||
            {
 | 
			
		||||
@@ -74,8 +75,8 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers
 | 
			
		||||
        public ActionResult DocContentEditModule(string id)
 | 
			
		||||
        {
 | 
			
		||||
            ViewBag.DocumentTypeList = DocumentTypeDAL.Query(w => w.Status == 1).list.Select(s => new SelectListItem { Text = s.TypeName, Value = s.ID.ToString() }).ToList();
 | 
			
		||||
            DocumentContent model = new DocumentContent();
 | 
			
		||||
            if (!string.IsNullOrEmpty(id))
 | 
			
		||||
            DocumentContent model = new DocumentContent() { OriginType = 0};
 | 
			
		||||
            if (!string.IsNullOrEmpty(id) && id != "0")
 | 
			
		||||
            {
 | 
			
		||||
                int _id = Convert.ToInt32(id);
 | 
			
		||||
                model = DocumentContentDAL.GetByOne(w => w.ID == _id);
 | 
			
		||||
 
 | 
			
		||||
@@ -3,30 +3,19 @@
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="utf-8" />
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 | 
			
		||||
    <title>@ViewData["Title"] - FreeSql.Site.UI</title>
 | 
			
		||||
    <title>@ViewData["Title"]</title>
 | 
			
		||||
 | 
			
		||||
    <environment include="Development">
 | 
			
		||||
        <link href="~/layui/css/layui.css" rel="stylesheet" />
 | 
			
		||||
        <link href="~/lib/editormd/css/editormd.min.css" rel="stylesheet" />
 | 
			
		||||
        <link href="~/lib/editormd/css/editormd.preview.min.css" rel="stylesheet" />
 | 
			
		||||
 | 
			
		||||
        <link href="~/layui/lay/modules/preview.css" rel="stylesheet" />
 | 
			
		||||
        <link href="~/css/admin.css" rel="stylesheet" />
 | 
			
		||||
        <script src="~/lib/jquery/dist/jquery.js"></script>
 | 
			
		||||
        <script src="~/js/common.js"></script>
 | 
			
		||||
        @*<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>*@
 | 
			
		||||
        <script src="~/lib/editormd/src/editormd.js"></script>
 | 
			
		||||
 | 
			
		||||
        <!-- 页面markdown解析成HTML需要的js -->
 | 
			
		||||
        <script src="~/lib/editormd/lib/marked.min.js"></script>
 | 
			
		||||
        <script src="~/lib/editormd/lib/prettify.min.js"></script>
 | 
			
		||||
        <script src="~/lib/editormd/lib/raphael.min.js"></script>
 | 
			
		||||
        <script src="~/lib/editormd/lib/underscore.min.js"></script>
 | 
			
		||||
        <script src="~/lib/editormd/lib/sequence-diagram.min.js"></script>
 | 
			
		||||
        <script src="~/lib/editormd/lib/flowchart.min.js"></script>
 | 
			
		||||
        <script src="~/lib/editormd/lib/jquery.flowchart.min.js"></script>
 | 
			
		||||
 | 
			
		||||
        <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
 | 
			
		||||
        <script src="https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script>
 | 
			
		||||
        <script src="~/layui/lay/modules/layer.js"></script>
 | 
			
		||||
        <script src="~/layui/layui.js"></script>
 | 
			
		||||
    </environment>
 | 
			
		||||
    <environment exclude="Development">
 | 
			
		||||
 
 | 
			
		||||
@@ -35,10 +35,22 @@
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
    var contentEdit;
 | 
			
		||||
    layui.use(['form', 'table'], function () {
 | 
			
		||||
    layui.use(['layer', 'laymd', 'form', 'table'], function () {
 | 
			
		||||
        var table = layui.table;
 | 
			
		||||
        var form = layui.form
 | 
			
		||||
            , layer = layui.layer;
 | 
			
		||||
            , layer = layui.layer, laymd = layui.laymd;
 | 
			
		||||
 | 
			
		||||
        var loadMarkDown = function () {
 | 
			
		||||
            //实例化编辑器,可以多个实例
 | 
			
		||||
            var md = laymd.init('DocContent', {});
 | 
			
		||||
            //内容改变事件
 | 
			
		||||
            md.on('change', function () {
 | 
			
		||||
                //这里借用marked.js解析效率比HyperDown快,用户可自行找解析器
 | 
			
		||||
                this.setPreview(marked(this.getText()));
 | 
			
		||||
            });
 | 
			
		||||
            //初始化数据预览
 | 
			
		||||
            md.do('change');
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        table.render({
 | 
			
		||||
@@ -97,14 +109,39 @@
 | 
			
		||||
            switch (obj.event) {
 | 
			
		||||
                case 'add':
 | 
			
		||||
                    var options = {
 | 
			
		||||
                        url: "/Admin/Document/DocContentEditModule", paramters: { id: "" },
 | 
			
		||||
                        url: "/Admin/Document/DocContentEditModule", paramters: { id: "0" },
 | 
			
		||||
                        title: "新增文档",
 | 
			
		||||
                        area: ['1100px', '660px'],
 | 
			
		||||
                        submit: {
 | 
			
		||||
                            url: "/Admin/Document/DocContentCreate",
 | 
			
		||||
                        },
 | 
			
		||||
                        elmid: "docContentEdit",
 | 
			
		||||
                        callback: reloadTable
 | 
			
		||||
                        callback: reloadTable,
 | 
			
		||||
                        loadBefore: function () {
 | 
			
		||||
                            //监听指定开关
 | 
			
		||||
                            form.on('switch(switchTest)', function (data) {
 | 
			
		||||
                                if (this.checked) {
 | 
			
		||||
                                    $("#OriginUrlArea").hide();
 | 
			
		||||
                                    $("#DocContentArea").show();
 | 
			
		||||
                                }
 | 
			
		||||
                                else {
 | 
			
		||||
                                    $("#OriginUrlArea").show();
 | 
			
		||||
                                    $("#DocContentArea").hide();
 | 
			
		||||
 | 
			
		||||
                                }
 | 
			
		||||
                            });
 | 
			
		||||
                            //contentEdit = editormd("md_DocContent", {
 | 
			
		||||
                            //    width: "96%",
 | 
			
		||||
                            //    height: 640,
 | 
			
		||||
                            //    syncScrolling: "single",
 | 
			
		||||
                            //    path: "../../lib/editormd/lib/"
 | 
			
		||||
                            //});
 | 
			
		||||
                            loadMarkDown();
 | 
			
		||||
                        },
 | 
			
		||||
                        submitBefore: function (data) {
 | 
			
		||||
                            data.field.OriginType = data.field.OriginType == "on" ? 1 : 0;
 | 
			
		||||
                            return data;
 | 
			
		||||
                        }
 | 
			
		||||
                    };
 | 
			
		||||
                    freejs.dialogWindow.create(options, form);
 | 
			
		||||
                    break;
 | 
			
		||||
@@ -149,7 +186,33 @@
 | 
			
		||||
                        url: "/Admin/Document/DocContentUpdate",
 | 
			
		||||
                    },
 | 
			
		||||
                    elmid: "docContentEdit",
 | 
			
		||||
                    callback: reloadTable
 | 
			
		||||
                    callback: reloadTable,
 | 
			
		||||
                    loadBefore: function () {
 | 
			
		||||
                        //监听指定开关
 | 
			
		||||
                        form.on('switch(switchTest)', function (data) {
 | 
			
		||||
                            if (this.checked) {
 | 
			
		||||
                                $("#OriginUrlArea").hide();
 | 
			
		||||
                                $("#DocContentArea").show();
 | 
			
		||||
                            }
 | 
			
		||||
                            else {
 | 
			
		||||
                                $("#OriginUrlArea").show();
 | 
			
		||||
                                $("#DocContentArea").hide();
 | 
			
		||||
 | 
			
		||||
                            }
 | 
			
		||||
                        });
 | 
			
		||||
                        //contentEdit = editormd("md_DocContent", {
 | 
			
		||||
                        //    width: "96%",
 | 
			
		||||
                        //    height: 640,
 | 
			
		||||
                        //    syncScrolling: "single",
 | 
			
		||||
                        //    path: "../../lib/editormd/lib/"
 | 
			
		||||
                        //});
 | 
			
		||||
                        loadMarkDown();
 | 
			
		||||
                    },
 | 
			
		||||
                    submitBefore: function (data) {
 | 
			
		||||
                        var _origintype = $(".layui-tab-title").find('.layui-this').attr("origintype");
 | 
			
		||||
                        data.field.OriginType = _origintype;
 | 
			
		||||
                        return data;
 | 
			
		||||
                    }
 | 
			
		||||
                };
 | 
			
		||||
                freejs.dialogWindow.create(options, form);
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -2,23 +2,17 @@
 | 
			
		||||
@model FreeSql.Site.Entity.DocumentContent
 | 
			
		||||
 | 
			
		||||
<form class="layui-form" action="" id="frm_DocContentEdit">
 | 
			
		||||
    @Html.HiddenFor(m => m.ID)
 | 
			
		||||
    @Html.HiddenFor(m => m.CreateBy)
 | 
			
		||||
    @Html.HiddenFor(m => m.CreateDt)
 | 
			
		||||
    @Html.HiddenFor(m => m.WatchCount)
 | 
			
		||||
    @Html.HiddenFor(m => m.StarCount)
 | 
			
		||||
    <div class="form-module-content">
 | 
			
		||||
        <div class="layui-form-item">
 | 
			
		||||
            <label class="layui-form-label">文章分类</label>
 | 
			
		||||
            <label class="layui-form-label">文章分类 </label>
 | 
			
		||||
            <div class="layui-input-block">
 | 
			
		||||
                @Html.HiddenFor(m => m.ID)
 | 
			
		||||
                @Html.HiddenFor(m => m.OriginType)
 | 
			
		||||
                @Html.HiddenFor(m => m.WatchCount)
 | 
			
		||||
                @Html.HiddenFor(m => m.StarCount)
 | 
			
		||||
                @Html.HiddenFor(m => m.CreateBy)
 | 
			
		||||
                @Html.HiddenFor(m => m.CreateDt)
 | 
			
		||||
                @Html.DropDownList("TypeID", ViewBag.DocumentTypeList as List<SelectListItem>, "", new Dictionary<string, object> { { "class", "plate_text" } })
 | 
			
		||||
                @*<select name="TypeID" lay-filter="aihao">
 | 
			
		||||
                    <option value="0" selected="selected">--请选择--</option>
 | 
			
		||||
                    @foreach (var item in (List<SelectListItem>)ViewBag.DocumentTypeList)
 | 
			
		||||
                    {
 | 
			
		||||
                        <option value="@item.Value">@item.Text</option>
 | 
			
		||||
                    }
 | 
			
		||||
                </select>*@
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
@@ -51,16 +45,38 @@
 | 
			
		||||
                <input type="radio" name="status" value="0" title="关闭">
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="layui-form-item layui-form-text">
 | 
			
		||||
            <label class="layui-form-label">文本域</label>
 | 
			
		||||
            <div class="layui-input-block" id="md_DocContent">
 | 
			
		||||
                @Html.TextAreaFor(m => m.DocContent, new Dictionary<string, object> { { "autocomplete", "off" }, { "placeholder", "请输入内容" } })
 | 
			
		||||
                @*<textarea style="display:none;" placeholder="请输入内容" name="DocContent"></textarea>*@
 | 
			
		||||
        @*<div class="layui-form-item">
 | 
			
		||||
                <label class="layui-form-label">来源类型</label>
 | 
			
		||||
                <div class="layui-input-block">
 | 
			
		||||
                    <input type="checkbox" id="OriginType" @(Model.OriginType == 1 ? "checked=''" : "") name="OriginType" lay-skin="switch" lay-filter="switchTest" lay-text="当前内容|URL地址">
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>*@
 | 
			
		||||
 | 
			
		||||
        <div class="layui-tab">
 | 
			
		||||
            <ul class="layui-tab-title">
 | 
			
		||||
                <li class=' @(Model.OriginType == 1 ? "" : "layui-this")' origintype="0">自有内容</li>
 | 
			
		||||
                <li class=' @(Model.OriginType == 1 ? "layui-this" : "")' origintype="1">外部来源</li>
 | 
			
		||||
            </ul>
 | 
			
		||||
            <div class="layui-tab-content">
 | 
			
		||||
                <div class='layui-tab-item  @(Model.OriginType == 1 ? "" : "layui-show")'>
 | 
			
		||||
                    <div class="layui-form-item layui-form-text" id="DocContentArea">
 | 
			
		||||
                        <div id="DocContent">@Model.DocContent</div>
 | 
			
		||||
                        @*@Html.TextAreaFor(m => m.DocContent, new Dictionary<string, object> { { "autocomplete", "off" }, { "placeholder", "请输入内容" } })*@
 | 
			
		||||
                        @*<textarea style="display:none;" placeholder="请输入内容" name="DocContent"></textarea>*@
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class='layui-tab-item  @(Model.OriginType == 1 ? "layui-show" : "")'>
 | 
			
		||||
                    <div class="layui-form-item" id="OriginUrlArea">
 | 
			
		||||
                        <label class="layui-form-label">外部来源</label>
 | 
			
		||||
                        <div class="layui-input-block">
 | 
			
		||||
                            @Html.TextBoxFor(m => m.OriginUrl, "", new Dictionary<string, object> { { "autocomplete", "off" }, { "class", "layui-input  " }, { "lay-verify", "title" }, { "placeholder", "请输入标题" } })
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="form-module-footer">
 | 
			
		||||
    @*<div class="form-module-footer">
 | 
			
		||||
        <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
 | 
			
		||||
    </div>
 | 
			
		||||
    </div>*@
 | 
			
		||||
</form>
 | 
			
		||||
@@ -11,8 +11,8 @@
 | 
			
		||||
<script>
 | 
			
		||||
    var dialog_Paramters = { height: 460, width: 600 };
 | 
			
		||||
</script>
 | 
			
		||||
<button class="layui-btn layui-btn-primary layui-btn-xs down-up-all">全部收起/展开</button>
 | 
			
		||||
<button class="layui-btn layui-btn-primary layui-btn-xs get-checked">获取选中</button>
 | 
			
		||||
<button class="layui-btn layui-btn-sm down-up-all" expandStatus="down">全部收起/展开</button>
 | 
			
		||||
<button class="layui-btn layui-btn-sm get-checked">获取选中</button>
 | 
			
		||||
 | 
			
		||||
<table class="layui-table layui-form" id="doctype-tree-table"></table>
 | 
			
		||||
 | 
			
		||||
@@ -42,7 +42,7 @@
 | 
			
		||||
                    {
 | 
			
		||||
                        field: 'title',
 | 
			
		||||
                        title: '标题',
 | 
			
		||||
                        width: '40%',
 | 
			
		||||
                        width: '45%',
 | 
			
		||||
                        template: function (item) {
 | 
			
		||||
                            if (item.level == 1) {
 | 
			
		||||
                                return '<span style="color:red;">' + item.title + '</span>';
 | 
			
		||||
@@ -53,11 +53,6 @@
 | 
			
		||||
                            return item.title;
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        field: 'id',
 | 
			
		||||
                        title: '编号',
 | 
			
		||||
                        width: '10%'
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        title: '标签',
 | 
			
		||||
                        width: '10%',
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,7 @@
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="form-module-footer">
 | 
			
		||||
    @*<div class="form-module-footer">
 | 
			
		||||
        <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
 | 
			
		||||
    </div>
 | 
			
		||||
    </div>*@
 | 
			
		||||
</form>
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
@{
 | 
			
		||||
    ViewBag.Title = "";
 | 
			
		||||
    ViewData["Title"] = ".NETCore最方便的ORM";
 | 
			
		||||
    Layout = "~/Areas/Admin/Shared/_Layout.cshtml";
 | 
			
		||||
}
 | 
			
		||||
<div class="layui-side layui-bg-black">
 | 
			
		||||
@@ -21,7 +21,7 @@
 | 
			
		||||
<div class="layui-body">
 | 
			
		||||
    <!-- 内容主体区域 -->
 | 
			
		||||
    <div style="padding: 15px;" id="page_content">
 | 
			
		||||
 | 
			
		||||
        文档主页引导
 | 
			
		||||
    </div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
@@ -32,7 +32,7 @@
 | 
			
		||||
 | 
			
		||||
        var index = freejs.showLoading({ msg: "数据加载中......" });
 | 
			
		||||
        var options = {
 | 
			
		||||
            url: path_item, paramters: $.parseJSON(path_json), loadIndex: index
 | 
			
		||||
            url: path_item, paramters: $.parseJSON(path_json), loadIndex: index, elm: "page_content"
 | 
			
		||||
        };
 | 
			
		||||
        freejs.loadHtml(options);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
@{
 | 
			
		||||
    Layout = null;
 | 
			
		||||
    ViewData["Title"] = ".NETCore最方便的ORM";
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,68 +4,53 @@
 | 
			
		||||
}
 | 
			
		||||
@if (ViewBag.DocumentInfo == null)
 | 
			
		||||
{
 | 
			
		||||
    <span style="font-size:20px; color:red;">
 | 
			
		||||
        编号: @ViewBag.DocumentID
 | 
			
		||||
    </span>
 | 
			
		||||
    <span>测试没有</span>
 | 
			
		||||
    <span>文章不存在,请选择其它文章查看!</span>
 | 
			
		||||
}
 | 
			
		||||
else
 | 
			
		||||
{
 | 
			
		||||
    <h1 class="site-h1">@*开始使用 - 入门指南*@@documentinfo.DocTitle</h1>
 | 
			
		||||
    <h1 class="site-h1">@documentinfo.DocTitle</h1>
 | 
			
		||||
    <div id="details_content" style="display:none;">
 | 
			
		||||
        @*<markdown>@documentinfo.DocContent</markdown>*@
 | 
			
		||||
        <blockquote>
 | 
			
		||||
            @documentinfo.DocAbstract
 | 
			
		||||
        </blockquote>
 | 
			
		||||
        @documentinfo.DocContent
 | 
			
		||||
        @*<blockquote class="layui-elem-quote">
 | 
			
		||||
                lFreeSql 是轻量化、可扩展和跨平台版的 .NETStandard 数据访问技术实现。<br />
 | 
			
		||||
                FreeSql 可用作对象关系映射程序 (O/RM),以便于开发人员能够使用 .NETStandard 对象来处理数据库,不必经常编写大部分数据访问代码。<br />
 | 
			
		||||
                FreeSql 支持 MySql/SqlServer/PostgreSQL 数据库技术实现。<br />
 | 
			
		||||
                FreeSql 打造 .NETCore 最方便的 ORM,dbfirst codefirst混合使用,codefirst模式下的开发阶段,建好实体不用执行任何操作,就能创建表和修改字段,dbfirst模式下提供api+模板,自定义生成代码,作者提供了3种模板。<br />
 | 
			
		||||
                FreeSql 目前仍处在测试阶段,您可以持续关注或者参与给出宝贵意见,QQ群:4336577
 | 
			
		||||
            </blockquote>
 | 
			
		||||
            <fieldset class="layui-elem-field layui-field-title site-title">
 | 
			
		||||
                <legend><a name="compatibility">兼容性和面向场景</a></legend>
 | 
			
		||||
            </fieldset>
 | 
			
		||||
            <div class="site-text">
 | 
			
		||||
                <p>1. 官网首页下载</p>
 | 
			
		||||
                <blockquote class="layui-elem-quote layui-quote-nm">
 | 
			
		||||
                    您可以通过 <a href="#">Github</a> 下载到FreeSql的最新版:
 | 
			
		||||
                </blockquote>
 | 
			
		||||
                <pre class="layui-code layui-box layui-code-view"><h3 class="layui-code-h3">code<a href="#" target="_blank">FreeSql</a></h3><ol class="layui-code-ol"><li>  ├─css //css目录</li><li>  │  │─modules //模块css目录(一般如果模块相对较大,我们会单独提取,比如下面三个:)</li><li>  │  │  ├─laydate</li><li>  │  │  ├─layer</li><li>  │  │  └─layim</li><li>  │  └─layui.css //核心样式文件</li><li>  ├─font  //字体图标目录</li><li>  ├─images //图片资源目录(目前只有layim和编辑器用到的GIF表情)</li><li>  │─lay //模块核心目录</li><li>  │  └─modules //各模块组件</li><li>  │─layui.js //基础核心库</li><li>  └─layui.all.js //包含layui.js和所有模块的合并文件</li><li>     </li></ol></pre>
 | 
			
		||||
                <p>2. Git 仓库下载</p>
 | 
			
		||||
                <blockquote class="layui-elem-quote layui-quote-nm">
 | 
			
		||||
                    你也可以通过 <a href="https://github.com/2881099/FreeSql/" target="_blank">GitHub</a> 或 <a href="https://gitee.com/sentsin/layui" target="_blank">码云</a> 得到 FreeSql 的完整开发包,以便于你进行二次开发,或者 Fork FreeSql 为我们贡献方案
 | 
			
		||||
                    <br><br>
 | 
			
		||||
                    <iframe src="//ghbtns.com/github-btn.html?user=2881099&repo=FreeSql&type=watch&count=true&size=large" allowtransparency="true" frameborder="0" scrolling="0" width="156px" height="30px"></iframe>
 | 
			
		||||
                    <iframe src="//ghbtns.com/github-btn.html?user=2881099&repo=FreeSql&type=fork&count=true&size=large" allowtransparency="true" frameborder="0" scrolling="0" width="156px" height="30px"></iframe>
 | 
			
		||||
                </blockquote>
 | 
			
		||||
                <p>3. npm 安装</p>
 | 
			
		||||
                <pre class="layui-code layui-box layui-code-view layui-code-notepad" lay-skin="notepad"><h3 class="layui-code-h3">code<a href="#" target="_blank">FreeSql</a></h3><ol class="layui-code-ol"><li> </li><li>Install-Package FreeSql    </li><li>      </li></ol></pre>
 | 
			
		||||
                <p>一般用于 WebPack 管理</p>
 | 
			
		||||
            </div>
 | 
			
		||||
            <fieldset class="layui-elem-field layui-field-title site-title">
 | 
			
		||||
                <legend><a name="quickstart">快速上手</a></legend>
 | 
			
		||||
            </fieldset>
 | 
			
		||||
            <div class="site-text">
 | 
			
		||||
                <p>1. 官网首页下载</p>
 | 
			
		||||
                <blockquote class="layui-elem-quote layui-quote-nm">
 | 
			
		||||
                    你可以在我们的 <a href="http://www.layui.com/">官网首页</a> 下载到 layui 的最新版,它经过了自动化构建,更适合用于生产环境。目录结构如下:
 | 
			
		||||
                </blockquote>
 | 
			
		||||
                <pre class="layui-code layui-box layui-code-view"><h3 class="layui-code-h3">code<a href="#" target="_blank">FreeSql</a></h3><ol class="layui-code-ol"><li>  ├─css //css目录</li><li>  │  │─modules //模块css目录(一般如果模块相对较大,我们会单独提取,比如下面三个:)</li><li>  │  │  ├─laydate</li><li>  │  │  ├─layer</li><li>  │  │  └─layim</li><li>  │  └─layui.css //核心样式文件</li><li>  ├─font  //字体图标目录</li><li>  ├─images //图片资源目录(目前只有layim和编辑器用到的GIF表情)</li><li>  │─lay //模块核心目录</li><li>  │  └─modules //各模块组件</li><li>  │─layui.js //基础核心库</li><li>  └─layui.all.js //包含layui.js和所有模块的合并文件</li><li>     </li></ol></pre>
 | 
			
		||||
            </div>*@
 | 
			
		||||
    </div>
 | 
			
		||||
    <script>
 | 
			
		||||
        marked.setOptions({
 | 
			
		||||
            renderer: new marked.Renderer(),
 | 
			
		||||
            gfm: true,
 | 
			
		||||
            tables: true,
 | 
			
		||||
            breaks: true,
 | 
			
		||||
            pedantic: false,
 | 
			
		||||
            sanitize: false,
 | 
			
		||||
            smartLists: true,
 | 
			
		||||
            smartypants: false,
 | 
			
		||||
        });
 | 
			
		||||
        document.getElementById('details_content').innerHTML =
 | 
			
		||||
            marked($("#details_content").html());
 | 
			
		||||
        if ('@documentinfo.OriginType' == '1') {
 | 
			
		||||
            var options = {
 | 
			
		||||
                elm: "details_content", url: "@documentinfo.OriginUrl", paramters: "", loadIndex: 1,
 | 
			
		||||
                successCallBack: function () {
 | 
			
		||||
                    debugger
 | 
			
		||||
                    document.getElementById('details_content').innerHTML =
 | 
			
		||||
                        marked($("#details_content").html());
 | 
			
		||||
                }
 | 
			
		||||
            };
 | 
			
		||||
            freejs.loadHtml(options);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            if ('@documentinfo.EditorMode' == '0') {
 | 
			
		||||
                marked.setOptions({
 | 
			
		||||
                    renderer: new marked.Renderer(),
 | 
			
		||||
                    gfm: true,
 | 
			
		||||
                    tables: true,
 | 
			
		||||
                    breaks: true,
 | 
			
		||||
                    pedantic: false,
 | 
			
		||||
                    sanitize: false,
 | 
			
		||||
                    smartLists: true,
 | 
			
		||||
                    smartypants: false,
 | 
			
		||||
                });
 | 
			
		||||
                marked.setOptions({
 | 
			
		||||
                    highlight: function (code) {
 | 
			
		||||
                        return hljs.highlightAuto(code).value;
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                document.getElementById('details_content').innerHTML =
 | 
			
		||||
                    marked($("#details_content").html());
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                //直接里面的内容就是HTML
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        $("#details_content").show();
 | 
			
		||||
    </script>
 | 
			
		||||
}
 | 
			
		||||
@@ -16,7 +16,9 @@
 | 
			
		||||
    <Folder Include="Areas\Doc\Models\" />
 | 
			
		||||
    <Folder Include="Areas\Example\Data\" />
 | 
			
		||||
    <Folder Include="Areas\Example\Models\" />
 | 
			
		||||
    <Folder Include="wwwroot\laymd\" />
 | 
			
		||||
    <Folder Include="wwwroot\layui\ext\treetable\js\" />
 | 
			
		||||
    <Folder Include="wwwroot\file\" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
@{
 | 
			
		||||
    ViewData["Title"] = "Home Page";
 | 
			
		||||
    ViewData["Title"] = ".NETCore最方便的ORM";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
<div class="site-banner">
 | 
			
		||||
 
 | 
			
		||||
@@ -3,17 +3,19 @@
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="utf-8" />
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 | 
			
		||||
    <title>@ViewData["Title"] - FreeSql.Site.UI</title>
 | 
			
		||||
    <title>@ViewData["Title"]</title>
 | 
			
		||||
 | 
			
		||||
    <environment include="Development">
 | 
			
		||||
        <link href="~/layui/css/layui.css" rel="stylesheet" />
 | 
			
		||||
        <link href="~/layui/lay/modules/preview.css" rel="stylesheet" />
 | 
			
		||||
        <link rel="stylesheet" href="~/css/site.css" />
 | 
			
		||||
        <link rel="stylesheet" href="https://cdn.bootcss.com/highlight.js/9.11.0/styles/github.min.css" />
 | 
			
		||||
        <script src="~/lib/jquery/dist/jquery.js"></script>
 | 
			
		||||
        <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
 | 
			
		||||
        <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
 | 
			
		||||
        <script src="https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script>
 | 
			
		||||
 | 
			
		||||
        <script src="~/layui/layui.js"></script>
 | 
			
		||||
        <script src="~/layui/lay/modules/layer.js"></script>
 | 
			
		||||
        <script src="~/js/common.js"></script>
 | 
			
		||||
    </environment>
 | 
			
		||||
    <environment exclude="Development">
 | 
			
		||||
        <link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										129
									
								
								Examples/website/FreeSql.Site.UI/wwwroot/file/codefirst.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,129 @@
 | 
			
		||||
# CodeFirst
 | 
			
		||||
 | 
			
		||||
| 数据库 | 支持的类型类型 |
 | 
			
		||||
| - | - |
 | 
			
		||||
| MySql | bool, sbyte, short, int, long, byte, ushort, uint, ulong, double, float, decimal, Guid, TimeSpan, DateTime<br>bool?, sbyte?, short?, int?, long?, byte?, ushort?, uint?, ulong?, double?, float?, decimal?, Guid?, TimeSpan?, DateTime?<br>byte[], string, Enum & FlagsEnum<br>MygisPoint, MygisLineString, MygisPolygon, MygisMultiPoint, MygisMultiLineString, MygisMultiPolygon |
 | 
			
		||||
| SqlServer | bool, sbyte, short, int, long, byte, ushort, uint, ulong, double, float, decimal, Guid, TimeSpan, DateTime, DateTimeOffset<br>bool?, sbyte?, short?, int?, long?, byte?, ushort?, uint?, ulong?, double?, float?, decimal?, Guid?, TimeSpan?, DateTime?, DateTimeOffset?<br>byte[], string, Enum & FlagsEnum |
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
 | 
			
		||||
    .UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
 | 
			
		||||
    .Build();
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 自动同步实体结构【开发环境必备】
 | 
			
		||||
 | 
			
		||||
自动同步实体结构到数据库,程序运行中检查实体表是否存在,然后创建或修改
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
fsql.CodeFirst.IsAutoSyncDataStructure = true;
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
> 此功能默认为开启状态,发布正式环境后,请修改此设置
 | 
			
		||||
 | 
			
		||||
> 虽然【自动同步实体结构】功能开发非常好用,但是有个坏处,就是数据库后面会很乱,没用的字段一大堆
 | 
			
		||||
 | 
			
		||||
### 手工同步实体结构
 | 
			
		||||
 | 
			
		||||
| 实体&表对比 | 添加 | 改名 | 删除 |
 | 
			
		||||
| - | - | - | - |
 | 
			
		||||
|  | √ | √ | X |
 | 
			
		||||
 | 
			
		||||
| 实体属性&字段对比 | 添加 | 修改可空 | 修改自增 | 修改类型 | 改名 | 删除 |
 | 
			
		||||
| - | - | - | - | - | - | - |
 | 
			
		||||
|  | √ | √ | √ | √ | √ | X |
 | 
			
		||||
 | 
			
		||||
> 为了保证安全,不提供删除字段
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
1、提供方法对比实体,与数据库中的变化部分
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var t1 = mysql.CodeFirst.GetComparisonDDLStatements<Topic>();
 | 
			
		||||
 | 
			
		||||
class Topic {
 | 
			
		||||
	[Column(IsIdentity = true, IsPrimary = true)]
 | 
			
		||||
	public int Id { get; set; }
 | 
			
		||||
	public int Clicks { get; set; }
 | 
			
		||||
	public TestTypeInfo Type { get; set; }
 | 
			
		||||
	public string Title { get; set; }
 | 
			
		||||
	public DateTime CreateTime { get; set; }
 | 
			
		||||
	public ushort fusho { get; set; }
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
```sql
 | 
			
		||||
CREATE TABLE IF NOT EXISTS `cccddd`.`Topic` ( 
 | 
			
		||||
  `Id` INT(11) NOT NULL AUTO_INCREMENT, 
 | 
			
		||||
  `Clicks` INT(11) NOT NULL, 
 | 
			
		||||
  `Title` VARCHAR(255), 
 | 
			
		||||
  `CreateTime` DATETIME NOT NULL, 
 | 
			
		||||
  `fusho` SMALLINT(5) UNSIGNED NOT NULL, 
 | 
			
		||||
  PRIMARY KEY (`Id`)
 | 
			
		||||
) Engine=InnoDB CHARACTER SET utf8;
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
2、指定实体的表名
 | 
			
		||||
 | 
			
		||||
指定 Name 后,实体类名变化不影响数据库对应的表
 | 
			
		||||
```csharp
 | 
			
		||||
[Table(Name = "tb_topic111")]
 | 
			
		||||
class Topic {
 | 
			
		||||
  //...
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
3、无指定实体的表名,修改实体类名
 | 
			
		||||
 | 
			
		||||
指定数据库旧的表名,修改实体命名时,同时设置此参数为修改之前的值,CodeFirst才可以正确修改数据库表;否则将视为【创建新表】
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
[Table(OldName = "Topic")]
 | 
			
		||||
class Topic2 {
 | 
			
		||||
  //...
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
```sql
 | 
			
		||||
ALTER TABLE `cccddd`.`Topic` RENAME TO `cccddd`.`Topic2`;
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
4、修改属性的类型
 | 
			
		||||
 | 
			
		||||
把 Id 类型改为 uint 后
 | 
			
		||||
```sql
 | 
			
		||||
ALTER TABLE `cccddd`.`Topic2` MODIFY `Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT;
 | 
			
		||||
```
 | 
			
		||||
```csharp
 | 
			
		||||
[Column(DbType = "varchar(128)")]
 | 
			
		||||
public string Title { get; set; }
 | 
			
		||||
```
 | 
			
		||||
```sql
 | 
			
		||||
ALTER TABLE `cccddd`.`Topic2` MODIFY `Title2` VARCHAR(128);
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
5、指定属性的字段名
 | 
			
		||||
 | 
			
		||||
这样指定后,修改实体的属性名不影响数据库对应的列
 | 
			
		||||
```csharp
 | 
			
		||||
[Column(Name = "titl2")]
 | 
			
		||||
public string Title { get; set; }
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
6、无指定属性的字段名,修改属性名
 | 
			
		||||
 | 
			
		||||
指定数据库旧的列名,修改实体属性命名时,同时设置此参数为修改之前的值,CodeFirst才可以正确修改数据库字段;否则将视为【新增字段】
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
[Column(OldName = "Title2")]
 | 
			
		||||
public string Title { get; set; }
 | 
			
		||||
```
 | 
			
		||||
```sql
 | 
			
		||||
ALTER TABLE `cccddd`.`Topic2` CHANGE COLUMN `Title2` `Title` VARCHAR(255);
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
7、提供方法同步结构
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var t2 = fsql.CodeFirst.SyncStructure<Topic>();
 | 
			
		||||
//同步实体类型到数据库
 | 
			
		||||
```
 | 
			
		||||
							
								
								
									
										109
									
								
								Examples/website/FreeSql.Site.UI/wwwroot/file/dbfirst.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,109 @@
 | 
			
		||||
# DbFirst
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
 | 
			
		||||
    .UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
 | 
			
		||||
    .Build();
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 获取所有数据库
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var t1 = fsql.DbFirst.GetDatabases();
 | 
			
		||||
//返回字符串数组, ["cccddd", "test"]
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 获取指定数据库的表信息
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var t2 = fsql.DbFirst.GetTablesByDatabase(fsql.DbFirst.GetDatabases()[0]);
 | 
			
		||||
//返回包括表、列详情、主键、唯一键、索引、外键
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# 生成器
 | 
			
		||||
 | 
			
		||||
生成器是基于 dbfirst 开发的辅助工具,适用老项目一键生成实体。生成器采用模板的方式,作者实现了三种生成模板:
 | 
			
		||||
 | 
			
		||||
| 模板名称 | 路径 | 类型映射 | 外键导航属性 | 缓存管理 | 失血 | 贫血 | 充血 |
 | 
			
		||||
| ------------- | - | - |- | - |- | - |- |
 | 
			
		||||
| simple-entity | ../Templates/MySql/simple-entity | √  | X | X | √ | X | X |
 | 
			
		||||
| simple-entity-navigation-object | ../Templates/MySql/simple-entity-navigation-object | √  | √ | X | √ | X | X |
 | 
			
		||||
| rich-entity-navigation-object | ../Templates/MySql/rich-entity-navigation-object | √  | √ | √ | X | √ | X |
 | 
			
		||||
 | 
			
		||||
> 更多模板逐步开发中。。。
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
//创建模板生成类现实
 | 
			
		||||
var gen = new FreeSql.Generator.TemplateGenerator();
 | 
			
		||||
gen.Build(fsql.DbFirst, 
 | 
			
		||||
    @"C:\Users\28810\Desktop\github\FreeSql\Templates\MySql\simple-entity",  //模板目录(事先下载)
 | 
			
		||||
    @"C:\Users\28810\Desktop\新建文件夹 (9)",  //生成后保存的目录
 | 
			
		||||
    "cccddd" //数据库
 | 
			
		||||
);
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## 模板语法
 | 
			
		||||
 | 
			
		||||
```html
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
<title>{#title}</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<!--绑定表达式-->
 | 
			
		||||
{#表达式}
 | 
			
		||||
{##表达式} 当表达式可能发生runtime错误时使用,性能没有上面的高
 | 
			
		||||
 | 
			
		||||
<!--可嵌套使用,同一标签最多支持3个指令-->
 | 
			
		||||
{include ../header.html}
 | 
			
		||||
<div @for="i 1, 101">
 | 
			
		||||
  <p @if="i === 50" @for="item,index in data">aaa</p>
 | 
			
		||||
  <p @else="i % 3 === 0">bbb {#i}</p>
 | 
			
		||||
  <p @else="">ccc {#i}</p>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<!--定义模块,可以将公共模块定义到一个文件中-->
 | 
			
		||||
{module module_name1 parms1, 2, 3...}
 | 
			
		||||
{/module}
 | 
			
		||||
{module module_name2 parms1, 2, 3...}
 | 
			
		||||
{/module}
 | 
			
		||||
 | 
			
		||||
<!--使用模块-->
 | 
			
		||||
{import ../module.html as myname}
 | 
			
		||||
{#myname.module_name(parms1, 2, 3...)}
 | 
			
		||||
 | 
			
		||||
<!--继承-->
 | 
			
		||||
{extends ../inc/layout.html}
 | 
			
		||||
{block body}{/block}
 | 
			
		||||
 | 
			
		||||
<!--嵌入代码块-->
 | 
			
		||||
{%
 | 
			
		||||
for (var a = 0; a < 100; a++)
 | 
			
		||||
  print(a);
 | 
			
		||||
%}
 | 
			
		||||
 | 
			
		||||
<!--条件分支-->
 | 
			
		||||
{if i === 50}
 | 
			
		||||
{elseif i > 60}
 | 
			
		||||
{else}
 | 
			
		||||
{/if}
 | 
			
		||||
 | 
			
		||||
<!--三种循环-->
 | 
			
		||||
{for i 1,101}                可自定义名 {for index2 表达式1 in 表达式2}
 | 
			
		||||
 | 
			
		||||
{for item,index in items}    可选参数称 index
 | 
			
		||||
                             可自定义名 {for item2, index99 in 数组表达式}
 | 
			
		||||
 | 
			
		||||
{for key,item,index on json} 可选参数 item, index,
 | 
			
		||||
                             可自定义名 {for key2, item2, index99 in 对象表达式}
 | 
			
		||||
{/for}
 | 
			
		||||
 | 
			
		||||
<!--不被解析-->
 | 
			
		||||
{miss}
 | 
			
		||||
此块内容不被bmw.js解析
 | 
			
		||||
{/miss}
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
```
 | 
			
		||||
							
								
								
									
										82
									
								
								Examples/website/FreeSql.Site.UI/wwwroot/file/delete.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,82 @@
 | 
			
		||||
# 删除数据
 | 
			
		||||
 | 
			
		||||
| 方法 | 返回值 | 参数 | 描述 |
 | 
			
		||||
| - | - | - | - |
 | 
			
		||||
| Where | \<this\> | Lambda | 表达式条件,仅支持实体基础成员(不包含导航对象) |
 | 
			
		||||
| Where | \<this\> | string, parms | 原生sql语法条件,Where("id = ?id", new { id = 1 }) |
 | 
			
		||||
| Where | \<this\> | T1 \| IEnumerable<T1> | 传入实体或集合,将其主键作为条件 |
 | 
			
		||||
| WhereExists | \<this\> | ISelect | 子查询是否存在 |
 | 
			
		||||
| ToSql | string | | 返回即将执行的SQL语句 |
 | 
			
		||||
| ExecuteAffrows | long | | 执行SQL语句,返回影响的行数 |
 | 
			
		||||
| ExecuteDeleted | List\<T1\> | | 执行SQL语句,返回被删除的记录 |
 | 
			
		||||
 | 
			
		||||
### 测试代码
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
 | 
			
		||||
    .UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
 | 
			
		||||
    .Build();
 | 
			
		||||
IDelete<Topic> delete => fsql.Delete<Topic>();
 | 
			
		||||
 | 
			
		||||
[Table(Name = "tb_topic")]
 | 
			
		||||
class Topic {
 | 
			
		||||
    [Column(IsIdentity = true, IsPrimary = true)]
 | 
			
		||||
    public int Id { get; set; }
 | 
			
		||||
    public int Clicks { get; set; }
 | 
			
		||||
    public TestTypeInfo Type { get; set; }
 | 
			
		||||
    public string Title { get; set; }
 | 
			
		||||
    public DateTime CreateTime { get; set; }
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 动态条件
 | 
			
		||||
```csharp
 | 
			
		||||
Delete<Topic>(object dywhere)
 | 
			
		||||
```
 | 
			
		||||
dywhere 支持
 | 
			
		||||
 | 
			
		||||
* 主键值
 | 
			
		||||
* new[] { 主键值1, 主键值2 }
 | 
			
		||||
* Topic对象
 | 
			
		||||
* new[] { Topic对象1, Topic对象2 }
 | 
			
		||||
* new { id = 1 }
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var t1 = fsql.Delete<Topic>(new[] { 1, 2 }).ToSql();
 | 
			
		||||
//DELETE FROM `tb_topic` WHERE (`Id` = 1 OR `Id` = 2)
 | 
			
		||||
 | 
			
		||||
var t2 = fsql.Delete<Topic>(new Topic { Id = 1, Title = "test" }).ToSql();
 | 
			
		||||
//DELETE FROM `tb_topic` WHERE (`Id` = 1)
 | 
			
		||||
 | 
			
		||||
var t3 = fsql.Delete<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).ToSql();
 | 
			
		||||
//DELETE FROM `tb_topic` WHERE (`Id` = 1 OR `Id` = 2)
 | 
			
		||||
 | 
			
		||||
var t4 = fsql.Delete<Topic>(new { id = 1 }).ToSql();
 | 
			
		||||
//DELETE FROM `tb_topic` WHERE (`Id` = 1)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 删除条件
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var t5 = delete.Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
 | 
			
		||||
//DELETE FROM `tb_topic` WHERE (`Id` = 1)
 | 
			
		||||
 | 
			
		||||
var t6 = delete.Where("id = ?id", new { id = 1 }).ToSql().Replace("\r\n", "");
 | 
			
		||||
//DELETE FROM `tb_topic` WHERE (id = ?id)
 | 
			
		||||
 | 
			
		||||
var item = new Topic { Id = 1, Title = "newtitle" };
 | 
			
		||||
var t7 = delete.Where(item).ToSql().Replace("\r\n", "");
 | 
			
		||||
//DELETE FROM `tb_topic` WHERE (`Id` = 1)
 | 
			
		||||
 | 
			
		||||
var items = new List<Topic>();
 | 
			
		||||
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 });
 | 
			
		||||
var t8 = delete.Where(items).ToSql().Replace("\r\n", "");
 | 
			
		||||
//DELETE FROM `tb_topic` WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 执行命令
 | 
			
		||||
 | 
			
		||||
| 方法 | 返回值 | 参数 | 描述 |
 | 
			
		||||
| - | - | - | - |
 | 
			
		||||
| ExecuteAffrows | long | | 执行SQL语句,返回影响的行数 |
 | 
			
		||||
| ExecuteDeleted | List\<T1\> | | 执行SQL语句,返回被删除的记录 |
 | 
			
		||||
							
								
								
									
										94
									
								
								Examples/website/FreeSql.Site.UI/wwwroot/file/generator.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,94 @@
 | 
			
		||||
# 生成器
 | 
			
		||||
 | 
			
		||||
生成器是基于 dbfirst 开发的辅助工具,适用老项目一键生成实体。生成器采用模板的方式,作者实现了三种生成模板:
 | 
			
		||||
 | 
			
		||||
| 模板名称 | 类型映射 | 外键导航属性 | 缓存管理 | 失血 | 贫血 | 充血 |
 | 
			
		||||
| ------------- | - | - |- | - |- | - |
 | 
			
		||||
| simple-entity | √  | X | X | √ | X | X |
 | 
			
		||||
| simple-entity-navigation-object | √  | √ | X | √ | X | X |
 | 
			
		||||
| rich-entity-navigation-object | √  | √ | √ | X | √ | X |
 | 
			
		||||
 | 
			
		||||
模板在项目目录:/Templates/MySql
 | 
			
		||||
 | 
			
		||||
> 更多模板逐步开发中。。。
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
//定义 mysql FreeSql
 | 
			
		||||
var mysql = new FreeSql.FreeSqlBuilder()
 | 
			
		||||
    .UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
 | 
			
		||||
    .Build();
 | 
			
		||||
 | 
			
		||||
//创建模板生成类现实
 | 
			
		||||
var gen = new FreeSql.Generator.TemplateGenerator();
 | 
			
		||||
gen.Build(mysql.DbFirst, 
 | 
			
		||||
    @"C:\Users\28810\Desktop\github\FreeSql\Templates\MySql\simple-entity",  //模板目录(事先下载)
 | 
			
		||||
    @"C:\Users\28810\Desktop\新建文件夹 (9)",  //生成后保存的目录
 | 
			
		||||
    "cccddd" //数据库
 | 
			
		||||
);
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## 模板语法
 | 
			
		||||
 | 
			
		||||
```html
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
<title>{#title}</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<!--绑定表达式-->
 | 
			
		||||
{#表达式}
 | 
			
		||||
{##表达式} 当表达式可能发生runtime错误时使用,性能没有上面的高
 | 
			
		||||
 | 
			
		||||
<!--可嵌套使用,同一标签最多支持3个指令-->
 | 
			
		||||
{include ../header.html}
 | 
			
		||||
<div @for="i 1, 101">
 | 
			
		||||
  <p @if="i === 50" @for="item,index in data">aaa</p>
 | 
			
		||||
  <p @else="i % 3 === 0">bbb {#i}</p>
 | 
			
		||||
  <p @else="">ccc {#i}</p>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<!--定义模块,可以将公共模块定义到一个文件中-->
 | 
			
		||||
{module module_name1 parms1, 2, 3...}
 | 
			
		||||
{/module}
 | 
			
		||||
{module module_name2 parms1, 2, 3...}
 | 
			
		||||
{/module}
 | 
			
		||||
 | 
			
		||||
<!--使用模块-->
 | 
			
		||||
{import ../module.html as myname}
 | 
			
		||||
{#myname.module_name(parms1, 2, 3...)}
 | 
			
		||||
 | 
			
		||||
<!--继承-->
 | 
			
		||||
{extends ../inc/layout.html}
 | 
			
		||||
{block body}{/block}
 | 
			
		||||
 | 
			
		||||
<!--嵌入代码块-->
 | 
			
		||||
{%
 | 
			
		||||
for (var a = 0; a < 100; a++)
 | 
			
		||||
  print(a);
 | 
			
		||||
%}
 | 
			
		||||
 | 
			
		||||
<!--条件分支-->
 | 
			
		||||
{if i === 50}
 | 
			
		||||
{elseif i > 60}
 | 
			
		||||
{else}
 | 
			
		||||
{/if}
 | 
			
		||||
 | 
			
		||||
<!--三种循环-->
 | 
			
		||||
{for i 1,101}                可自定义名 {for index2 表达式1 in 表达式2}
 | 
			
		||||
 | 
			
		||||
{for item,index in items}    可选参数称 index
 | 
			
		||||
                             可自定义名 {for item2, index99 in 数组表达式}
 | 
			
		||||
 | 
			
		||||
{for key,item,index on json} 可选参数 item, index,
 | 
			
		||||
                             可自定义名 {for key2, item2, index99 in 对象表达式}
 | 
			
		||||
{/for}
 | 
			
		||||
 | 
			
		||||
<!--不被解析-->
 | 
			
		||||
{miss}
 | 
			
		||||
此块内容不被bmw.js解析
 | 
			
		||||
{/miss}
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
```
 | 
			
		||||
							
								
								
									
										79
									
								
								Examples/website/FreeSql.Site.UI/wwwroot/file/insert.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,79 @@
 | 
			
		||||
# 插入数据
 | 
			
		||||
 | 
			
		||||
| 方法 | 返回值 | 参数 | 描述 |
 | 
			
		||||
| - | - | - | - |
 | 
			
		||||
| AppendData | \<this\> | T1 \| IEnumerable<T1> | 追加准备插入的实体 |
 | 
			
		||||
| InsertColumns | \<this\> | Lambda | 只插入的列 |
 | 
			
		||||
| IgnoreColumns | \<this\> | Lambda | 忽略的列 |
 | 
			
		||||
| ToSql | string | | 返回即将执行的SQL语句 |
 | 
			
		||||
| ExecuteAffrows | long | | 执行SQL语句,返回影响的行数 |
 | 
			
		||||
| ExecuteIdentity | long | | 执行SQL语句,返回自增值 |
 | 
			
		||||
| ExecuteInserted | List\<T1\> | | 执行SQL语句,返回插入后的记录 |
 | 
			
		||||
 | 
			
		||||
### 列优先级
 | 
			
		||||
 | 
			
		||||
> 全部列 < 指定列(InsertColumns) < 忽略列(IgnoreColumns)
 | 
			
		||||
 | 
			
		||||
### 测试代码
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
 | 
			
		||||
    .UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
 | 
			
		||||
    .Build();
 | 
			
		||||
IInsert<Topic> insert => fsql.Insert<Topic>();
 | 
			
		||||
 | 
			
		||||
[Table(Name = "tb_topic")]
 | 
			
		||||
class Topic {
 | 
			
		||||
    [Column(IsIdentity = true, IsPrimary = true)]
 | 
			
		||||
    public int Id { get; set; }
 | 
			
		||||
    public int Clicks { get; set; }
 | 
			
		||||
    public TestTypeInfo Type { get; set; }
 | 
			
		||||
    public string Title { get; set; }
 | 
			
		||||
    public DateTime CreateTime { get; set; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var items = new List<Topic>();
 | 
			
		||||
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 });
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 插入
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var t1 = insert.AppendData(items.First()).ToSql();
 | 
			
		||||
//INSERT INTO `tb_topic`(`Clicks`, `Title`, `CreateTime`) VALUES(?Clicks0, ?Title0, ?CreateTime0)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 批量插入
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var t2 = insert.AppendData(items).ToSql();
 | 
			
		||||
//INSERT INTO `tb_topic`(`Clicks`, `Title`, `CreateTime`) VALUES(?Clicks0, ?Title0, ?CreateTime0), (?Clicks1, ?Title1, ?CreateTime1), (?Clicks2, ?Title2, ?CreateTime2), (?Clicks3, ?Title3, ?CreateTime3), (?Clicks4, ?Title4, ?CreateTime4), (?Clicks5, ?Title5, ?CreateTime5), (?Clicks6, ?Title6, ?CreateTime6), (?Clicks7, ?Title7, ?CreateTime7), (?Clicks8, ?Title8, ?CreateTime8), (?Clicks9, ?Title9, ?CreateTime9)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 只想插入指定的列
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var t3 = insert.AppendData(items).InsertColumns(a => a.Title).ToSql();
 | 
			
		||||
//INSERT INTO `tb_topic`(`Title`) VALUES(?Title0), (?Title1), (?Title2), (?Title3), (?Title4), (?Title5), (?Title6), (?Title7), (?Title8), (?Title9)
 | 
			
		||||
 | 
			
		||||
var t4 = insert.AppendData(items).InsertColumns(a =>new { a.Title, a.Clicks }).ToSql();
 | 
			
		||||
//INSERT INTO `tb_topic`(`Clicks`, `Title`) VALUES(?Clicks0, ?Title0), (?Clicks1, ?Title1), (?Clicks2, ?Title2), (?Clicks3, ?Title3), (?Clicks4, ?Title4), (?Clicks5, ?Title5), (?Clicks6, ?Title6), (?Clicks7, ?Title7), (?Clicks8, ?Title8), (?Clicks9, ?Title9)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 忽略列
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var t5 = insert.AppendData(items).IgnoreColumns(a => a.CreateTime).ToSql();
 | 
			
		||||
//INSERT INTO `tb_topic`(`Clicks`, `Title`) VALUES(?Clicks0, ?Title0), (?Clicks1, ?Title1), (?Clicks2, ?Title2), (?Clicks3, ?Title3), (?Clicks4, ?Title4), (?Clicks5, ?Title5), (?Clicks6, ?Title6), (?Clicks7, ?Title7), (?Clicks8, ?Title8), (?Clicks9, ?Title9)
 | 
			
		||||
 | 
			
		||||
var t6 = insert.AppendData(items).IgnoreColumns(a => new { a.Title, a.CreateTime }).ToSql();
 | 
			
		||||
///INSERT INTO `tb_topic`(`Clicks`) VALUES(?Clicks0), (?Clicks1), (?Clicks2), (?Clicks3), (?Clicks4), (?Clicks5), (?Clicks6), (?Clicks7), (?Clicks8), (?Clicks9)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 执行命令
 | 
			
		||||
 | 
			
		||||
| 方法 | 返回值 | 描述 |
 | 
			
		||||
| - | - | - |
 | 
			
		||||
| ExecuteAffrows | long | 执行SQL语句,返回影响的行数 |
 | 
			
		||||
| ExecuteIdentity | long | 执行SQL语句,返回自增值 |
 | 
			
		||||
| ExecuteInserted | List\<T1\> | 执行SQL语句,返回插入后的记录 |
 | 
			
		||||
							
								
								
									
										211
									
								
								Examples/website/FreeSql.Site.UI/wwwroot/file/select.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,211 @@
 | 
			
		||||
# 查询数据
 | 
			
		||||
 | 
			
		||||
## 测试代码
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
 | 
			
		||||
    .UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
 | 
			
		||||
    .Build();
 | 
			
		||||
ISelect<Topic> select => fsql.Select<Topic>();
 | 
			
		||||
 | 
			
		||||
[Table(Name = "tb_topic")]
 | 
			
		||||
class Topic {
 | 
			
		||||
    [Column(IsIdentity = true, IsPrimary = true)]
 | 
			
		||||
    public int Id { get; set; }
 | 
			
		||||
    public int Clicks { get; set; }
 | 
			
		||||
    public int TestTypeInfoGuid { get; set; }
 | 
			
		||||
    public TestTypeInfo Type { get; set; }
 | 
			
		||||
    public string Title { get; set; }
 | 
			
		||||
    public DateTime CreateTime { get; set; }
 | 
			
		||||
}
 | 
			
		||||
class TestTypeInfo {
 | 
			
		||||
    public int Guid { get; set; }
 | 
			
		||||
    public int ParentId { get; set; }
 | 
			
		||||
    public TestTypeParentInfo Parent { get; set; }
 | 
			
		||||
    public string Name { get; set; }
 | 
			
		||||
}
 | 
			
		||||
class TestTypeParentInfo {
 | 
			
		||||
    public int Id { get; set; }
 | 
			
		||||
    public string Name { get; set; }
 | 
			
		||||
 | 
			
		||||
    public List<TestTypeInfo> Types { get; set; }
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# Where
 | 
			
		||||
 | 
			
		||||
### 表达式函数支持
 | 
			
		||||
 | 
			
		||||
#### String 对象方法
 | 
			
		||||
StartsWith, EndsWith, Contains, ToLower, ToUpper, Substring, Length, IndexOf, PadLeft, PadRight, Trim, TrimStart, TrimEnd, Replace, CompareTo
 | 
			
		||||
 | 
			
		||||
#### Math 方法
 | 
			
		||||
...
 | 
			
		||||
 | 
			
		||||
### 单表
 | 
			
		||||
```csharp
 | 
			
		||||
var sql = select.Where(a => a.Id == 10).ToSql();
 | 
			
		||||
///SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a WHERE (a.`Id` = 10)
 | 
			
		||||
 | 
			
		||||
sql = select.Where(a => a.Id == 10 && a.Id > 10 || a.Clicks > 100).ToSql();
 | 
			
		||||
///SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a WHERE (a.`Id` = 10 AND a.`Id` > 10 OR a.`Clicks` > 100)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 多表,使用导航属性
 | 
			
		||||
```csharp
 | 
			
		||||
sql = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid).ToSql();
 | 
			
		||||
///SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TestTypeInfoGuid`)
 | 
			
		||||
 | 
			
		||||
sql = select.Where(a => a.Type.Parent.Name == "tparent").ToSql();
 | 
			
		||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeInfo` a__Type, `TestTypeParentInfo` a__Type__Parent WHERE (a__Type__Parent.`Name` = 'tparent')
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 多表,没有导航属性
 | 
			
		||||
```csharp
 | 
			
		||||
sql = select.Where<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "typeTitle").ToSql();
 | 
			
		||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeInfo` b WHERE (b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'typeTitle')
 | 
			
		||||
 | 
			
		||||
sql = select.Where<TestTypeInfo, TestTypeParentInfo>((a, b, c) => c.Name == "tparent").ToSql();
 | 
			
		||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a, `TestTypeParentInfo` c WHERE (c.`Name` = 'tparent')
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 多表,任意查
 | 
			
		||||
```csharp
 | 
			
		||||
sql = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
 | 
			
		||||
    .Where(a => a.Id == 10 && c.Name == "xxx")
 | 
			
		||||
    .Where(a => b.ParentId == 20)).ToSql();
 | 
			
		||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a, `TestTypeParentInfo` c, `TestTypeInfo` b WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 原生SQL
 | 
			
		||||
```csharp
 | 
			
		||||
sql = select.Where("a.clicks > 100 && a.id = ?id", new { id = 10 }).ToSql();
 | 
			
		||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a WHERE (a.clicks > 100 && a.id = ?id)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
> 以上条件查询,支持 WhereIf
 | 
			
		||||
 | 
			
		||||
# 联表
 | 
			
		||||
 | 
			
		||||
### 使用导航属性联表
 | 
			
		||||
```csharp
 | 
			
		||||
sql = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).ToSql();
 | 
			
		||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid`
 | 
			
		||||
 | 
			
		||||
sql = select
 | 
			
		||||
    .LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid)
 | 
			
		||||
    .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId).ToSql();
 | 
			
		||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` a__Type ON a__Type.`Guid` = a.`TestTypeInfoGuid` LEFT JOIN `TestTypeParentInfo` a__Type__Parent ON a__Type__Parent.`Id` = a__Type.`ParentId`
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 没有导航属性联表
 | 
			
		||||
```csharp
 | 
			
		||||
sql = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid).ToSql();
 | 
			
		||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid`
 | 
			
		||||
 | 
			
		||||
sql = select
 | 
			
		||||
    .LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid)
 | 
			
		||||
    .LeftJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId).ToSql();
 | 
			
		||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON b.`Guid` = a.`TestTypeInfoGuid` LEFT JOIN `TestTypeParentInfo` c ON c.`Id` = b.`ParentId`
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 联表任意查
 | 
			
		||||
```csharp
 | 
			
		||||
sql = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
 | 
			
		||||
    .LeftJoin(a => a.TestTypeInfoGuid == b.Guid)
 | 
			
		||||
    .LeftJoin(a => b.ParentId == c.Id)).ToSql();
 | 
			
		||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, b.`Guid` as4, b.`ParentId` as5, b.`Name` as6, a.`Title` as7, a.`CreateTime` as8 FROM `tb_topic` a LEFT JOIN `TestTypeInfo` b ON a.`TestTypeInfoGuid` = b.`Guid` LEFT JOIN `TestTypeParentInfo` c ON b.`ParentId` = c.`Id`
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 原生SQL联表
 | 
			
		||||
```csharp
 | 
			
		||||
sql = select.LeftJoin("TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname", new { bname = "xxx" }).ToSql();
 | 
			
		||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5 FROM `tb_topic` a LEFT JOIN TestTypeInfo b on b.Guid = a.TestTypeInfoGuid and b.Name = ?bname
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# 查询数据
 | 
			
		||||
 | 
			
		||||
### 返回 List
 | 
			
		||||
```csharp
 | 
			
		||||
List<Topic> t1 = select.Where(a => a.Id > 0).Skip(100).Limit(200).ToList();
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 返回 List + 导航属性的数据
 | 
			
		||||
```csharp
 | 
			
		||||
List<Topic> t2 = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid).ToList();
 | 
			
		||||
//此时会返回普通字段 + 导航对象 Type 的数据
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 指定字段返回
 | 
			
		||||
```csharp
 | 
			
		||||
//返回一个字段
 | 
			
		||||
List<int> t3 = select.Where(a => a.Id > 0).Skip(100).Limit(200).ToList(a => a.Id);
 | 
			
		||||
 | 
			
		||||
//返回匿名类
 | 
			
		||||
List<匿名类> t4 = select.Where(a => a.Id > 0).Skip(100).Limit(200).ToList(a => new { a.Id, a.Title });
 | 
			
		||||
 | 
			
		||||
//返回元组
 | 
			
		||||
List<(int, string)> t5 = select.Where(a => a.Id > 0).Skip(100).Limit(200).ToList<(int, string)>("id, title");
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 执行SQL返回数据
 | 
			
		||||
```csharp
 | 
			
		||||
class xxx {
 | 
			
		||||
    public int Id { get; set; }
 | 
			
		||||
    public string Path { get; set; }
 | 
			
		||||
    public string Title2 { get; set; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
List<xxx> t6 = fsql.Ado.Query<xxx>("select * from song");
 | 
			
		||||
List<(int, string ,string)> t7 = fsql.Ado.Query<(int, string, string)>("select * from song");
 | 
			
		||||
List<dynamic> t8 = fsql.Ado.Query<dynamic>("select * from song");
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# 更多文档整理中。。。
 | 
			
		||||
 | 
			
		||||
| 方法 | 返回值 | 参数 | 描述 |
 | 
			
		||||
| ------------- | - | - | - |
 | 
			
		||||
| ToSql | string | | 返回即将执行的SQL语句 |
 | 
			
		||||
| ToList | List<T1> | | 执行SQL查询,返回 T1 实体所有字段的记录,若存在导航属性则一起查询返回,记录不存在时返回 Count 为 0 的列表 |
 | 
			
		||||
| ToList\<T\> | List\<T\> | Lambda | 执行SQL查询,返回指定字段的记录,记录不存在时返回 Count 为 0 的列表 |
 | 
			
		||||
| ToList\<T\> | List\<T\> | string field | 执行SQL查询,返回 field 指定字段的记录,并以元组或基础类型(int,string,long)接收,记录不存在时返回 Count 为 0 的列表 |
 | 
			
		||||
| ToOne | T1 | | 执行SQL查询,返回 T1 实体所有字段的第一条记录,记录不存在时返回 null |
 | 
			
		||||
| Any | bool | | 执行SQL查询,是否有记录 |
 | 
			
		||||
| Sum | T | Lambda | 指定一个列求和 |
 | 
			
		||||
| Min | T | Lambda | 指定一个列求最小值 |
 | 
			
		||||
| Max | T | Lambda | 指定一个列求最大值 |
 | 
			
		||||
| Avg | T | Lambda | 指定一个列求平均值 |
 | 
			
		||||
| 【分页】 |
 | 
			
		||||
| Count | long | | 查询的记录数量 |
 | 
			
		||||
| Count | \<this\> | out long | 查询的记录数量,以参数out形式返回 |
 | 
			
		||||
| Skip | \<this\> | int offset | 查询向后偏移行数 |
 | 
			
		||||
| Offset | \<this\> | int offset | 查询向后偏移行数 |
 | 
			
		||||
| Limit | \<this\> | int limit | 查询多少条数据 |
 | 
			
		||||
| Take | \<this\> | int limit | 查询多少条数据 |
 | 
			
		||||
| Page | \<this\> | int pageIndex, int pageSize | 分页 |
 | 
			
		||||
| 【条件】 |
 | 
			
		||||
| Where | \<this\> | Lambda | 支持多表查询表达式 |
 | 
			
		||||
| WhereIf | \<this\> | bool, Lambda | 支持多表查询表达式 |
 | 
			
		||||
| Where | \<this\> | string, parms | 原生sql语法条件,Where("id = ?id", new { id = 1 }) |
 | 
			
		||||
| WhereIf | \<this\> | bool, string, parms | 原生sql语法条件,WhereIf(true, "id = ?id", new { id = 1 }) |
 | 
			
		||||
| WhereLike | \<this\> | Lambda, string, bool | like 查询条件,where title like '%xxx%' or content like '%xxx%' |
 | 
			
		||||
| 【分组】 |
 | 
			
		||||
| GroupBy | \<this\> | Lambda | 按选择的列分组,GroupBy(a => a.Name) | GroupBy(a => new{a.Name,a.Time}) | GroupBy(a => new[]{"name","time"}) |
 | 
			
		||||
| GroupBy | \<this\> | string, parms | 按原生sql语法分组,GroupBy("concat(name, ?cc)", new { cc = 1 }) |
 | 
			
		||||
| Having | \<this\> | string, parms | 按原生sql语法聚合条件过滤,Having("count(name) = ?cc", new { cc = 1 }) |
 | 
			
		||||
| 【排序】 |
 | 
			
		||||
| OrderBy | \<this\> | Lambda | 按列排序,OrderBy(a => a.Time) |
 | 
			
		||||
| OrderByDescending | \<this\> | Lambda | 按列倒向排序,OrderByDescending(a => a.Time) |
 | 
			
		||||
| OrderBy | \<this\> | string, parms | 按原生sql语法排序,OrderBy("count(name) + ?cc", new { cc = 1 }) |
 | 
			
		||||
| 【联表】 |
 | 
			
		||||
| LeftJoin | \<this\> | Lambda | 左联查询,可使用导航属性,或指定关联的实体类型 |
 | 
			
		||||
| InnerJoin | \<this\> | Lambda | 联接查询,可使用导航属性,或指定关联的实体类型 |
 | 
			
		||||
| RightJoin | \<this\> | Lambda | 右联查询,可使用导航属性,或指定关联的实体类型 |
 | 
			
		||||
| LeftJoin | \<this\> | string, parms | 左联查询,使用原生sql语法,LeftJoin("type b on b.id = a.id and b.clicks > ?clicks", new { clicks = 1 }) |
 | 
			
		||||
| InnerJoin | \<this\> | string, parms | 联接查询,使用原生sql语法,InnerJoin("type b on b.id = a.id and b.clicks > ?clicks", new { clicks = 1 }) |
 | 
			
		||||
| RightJoin | \<this\> | string, parms | 右联查询,使用原生sql语法,RightJoin("type b on b.id = a.id and b.clicks > ?clicks", new { clicks = 1 }) |
 | 
			
		||||
| From | \<this\> | Lambda | 多表查询,3个表以上使用非常方便,目前设计最大支持10个表 |
 | 
			
		||||
| 【其他】 |
 | 
			
		||||
| As | \<this\> | string alias = "a" | 指定别名 |
 | 
			
		||||
| Master | \<this\> | | 指定从主库查询(默认查询从库) |
 | 
			
		||||
| Caching | \<this\> | int seconds, string key = null | 缓存查询结果 |
 | 
			
		||||
							
								
								
									
										129
									
								
								Examples/website/FreeSql.Site.UI/wwwroot/file/update.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,129 @@
 | 
			
		||||
# 更新数据
 | 
			
		||||
 | 
			
		||||
| 方法 | 返回值 | 参数 | 描述 |
 | 
			
		||||
| - | - | - | - |
 | 
			
		||||
| SetSource | \<this\> | T1 \| IEnumerable<T1> | 更新数据,设置更新的实体 |
 | 
			
		||||
| IgnoreColumns | \<this\> | Lambda | 忽略的列 |
 | 
			
		||||
| Set | \<this\> | Lambda, value | 设置列的新值,Set(a => a.Name, "newvalue") |
 | 
			
		||||
| Set | \<this\> | Lambda | 设置列的的新值为基础上增加,Set(a => a.Clicks + 1),相当于 clicks=clicks+1; |
 | 
			
		||||
| SetRaw | \<this\> | string, parms | 设置值,自定义SQL语法,SetRaw("title = ?title", new { title = "newtitle" }) |
 | 
			
		||||
| Where | \<this\> | Lambda | 表达式条件,仅支持实体基础成员(不包含导航对象) |
 | 
			
		||||
| Where | \<this\> | string, parms | 原生sql语法条件,Where("id = ?id", new { id = 1 }) |
 | 
			
		||||
| Where | \<this\> | T1 \| IEnumerable<T1> | 传入实体或集合,将其主键作为条件 |
 | 
			
		||||
| WhereExists | \<this\> | ISelect | 子查询是否存在 |
 | 
			
		||||
| ToSql | string | | 返回即将执行的SQL语句 |
 | 
			
		||||
| ExecuteAffrows | long | | 执行SQL语句,返回影响的行数 |
 | 
			
		||||
| ExecuteUpdated | List\<T1\> | | 执行SQL语句,返回更新后的记录 |
 | 
			
		||||
 | 
			
		||||
### 列优先级
 | 
			
		||||
 | 
			
		||||
> 全部列 < 指定列(Set/SetRaw) < 忽略列(IgnoreColumns)
 | 
			
		||||
 | 
			
		||||
### 测试代码
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
[Table(Name = "tb_topic")]
 | 
			
		||||
class Topic {
 | 
			
		||||
	[Column(IsIdentity = true, IsPrimary = true)]
 | 
			
		||||
	public int Id { get; set; }
 | 
			
		||||
	public int Clicks { get; set; }
 | 
			
		||||
	public TestTypeInfo Type { get; set; }
 | 
			
		||||
	public string Title { get; set; }
 | 
			
		||||
	public DateTime CreateTime { get; set; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
 | 
			
		||||
    .UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
 | 
			
		||||
    .Build();
 | 
			
		||||
IUpdate<Topic> update => fsql.Update<Topic>();
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 动态条件
 | 
			
		||||
```csharp
 | 
			
		||||
Update<Topic>(object dywhere)
 | 
			
		||||
```
 | 
			
		||||
dywhere 支持
 | 
			
		||||
 | 
			
		||||
* 主键值
 | 
			
		||||
* new[] { 主键值1, 主键值2 }
 | 
			
		||||
* Topic对象
 | 
			
		||||
* new[] { Topic对象1, Topic对象2 }
 | 
			
		||||
* new { id = 1 }
 | 
			
		||||
 | 
			
		||||
### 更新指定列
 | 
			
		||||
```csharp
 | 
			
		||||
var t1 = fsql.Update<Topic>(1).Set(a => a.CreateTime, DateTime.Now).ToSql();
 | 
			
		||||
//UPDATE `tb_topic` SET `CreateTime` = '2018-12-08 00:04:59' WHERE (`Id` = 1)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 更新指定列,累加
 | 
			
		||||
```csharp
 | 
			
		||||
var t2 = fsql.Update<Topic>(1).Set(a => a.Clicks + 1).ToSql();
 | 
			
		||||
//UPDATE `tb_topic` SET `Clicks` = ifnull(`Clicks`,0) + 1 WHERE (`Id` = 1)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 保存实体
 | 
			
		||||
```csharp
 | 
			
		||||
var item = new Topic { Id = 1, Title = "newtitle" };
 | 
			
		||||
var t3 = update.SetSource(item).ToSql();
 | 
			
		||||
//UPDATE `tb_topic` SET `Clicks` = ?p_0, `Title` = ?p_1, `CreateTime` = ?p_2 WHERE (`Id` = 1)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 保存实体,忽略一些列
 | 
			
		||||
```csharp
 | 
			
		||||
var t4 = update.SetSource(item).IgnoreColumns(a => a.Clicks).ToSql();
 | 
			
		||||
//UPDATE `tb_topic` SET `Title` = ?p_0, `CreateTime` = ?p_1 WHERE (`Id` = 1)
 | 
			
		||||
var t5 = update.SetSource(item).IgnoreColumns(a => new { a.Clicks, a.CreateTime }).ToSql();
 | 
			
		||||
//UPDATE `tb_topic` SET `Title` = ?p_0 WHERE (`Id` = 1)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 批量保存
 | 
			
		||||
```csharp
 | 
			
		||||
var items = new List<Topic>();
 | 
			
		||||
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 });
 | 
			
		||||
 | 
			
		||||
var t6 = update.SetSource(items).ToSql();
 | 
			
		||||
//UPDATE `tb_topic` SET `Clicks` = CASE `Id` WHEN 1 THEN ?p_0 WHEN 2 THEN ?p_1 WHEN 3 THEN ?p_2 WHEN 4 THEN ?p_3 WHEN 5 THEN ?p_4 WHEN 6 THEN ?p_5 WHEN 7 THEN ?p_6 WHEN 8 THEN ?p_7 WHEN 9 THEN ?p_8 WHEN 10 THEN ?p_9 END, `Title` = CASE `Id` WHEN 1 THEN ?p_10 WHEN 2 THEN ?p_11 WHEN 3 THEN ?p_12 WHEN 4 THEN ?p_13 WHEN 5 THEN ?p_14 WHEN 6 THEN ?p_15 WHEN 7 THEN ?p_16 WHEN 8 THEN ?p_17 WHEN 9 THEN ?p_18 WHEN 10 THEN ?p_19 END, `CreateTime` = CASE `Id` WHEN 1 THEN ?p_20 WHEN 2 THEN ?p_21 WHEN 3 THEN ?p_22 WHEN 4 THEN ?p_23 WHEN 5 THEN ?p_24 WHEN 6 THEN ?p_25 WHEN 7 THEN ?p_26 WHEN 8 THEN ?p_27 WHEN 9 THEN ?p_28 WHEN 10 THEN ?p_29 END WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
> 批量保存的场景,先查询20条记录,根据本地很复杂的规则把集合的值改完后
 | 
			
		||||
 | 
			
		||||
> 传统做法是循环20次保存,用 case when 只要一次就行
 | 
			
		||||
 | 
			
		||||
### 批量保存,忽略一些列
 | 
			
		||||
```csharp
 | 
			
		||||
var t7 = update.SetSource(items).IgnoreColumns(a => new { a.Clicks, a.CreateTime }).ToSql();
 | 
			
		||||
//UPDATE `tb_topic` SET `Title` = CASE `Id` WHEN 1 THEN ?p_0 WHEN 2 THEN ?p_1 WHEN 3 THEN ?p_2 WHEN 4 THEN ?p_3 WHEN 5 THEN ?p_4 WHEN 6 THEN ?p_5 WHEN 7 THEN ?p_6 WHEN 8 THEN ?p_7 WHEN 9 THEN ?p_8 WHEN 10 THEN ?p_9 END WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 批量更新指定列
 | 
			
		||||
```csharp
 | 
			
		||||
var t8 = update.SetSource(items).Set(a => a.CreateTime, DateTime.Now).ToSql();
 | 
			
		||||
//UPDATE `tb_topic` SET `CreateTime` = ?p_0 WHERE (`Id` IN (1,2,3,4,5,6,7,8,9,10))
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
> 指定列更新后,批量保存将失效
 | 
			
		||||
 | 
			
		||||
### 更新条件
 | 
			
		||||
 | 
			
		||||
> 除了顶上介绍的 dywhere 构造参数外,还支持 Where lambda/sql 方法
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var t9 = update.Set(a => a.Title, "新标题").Where(a => a.Id == 1).ToSql();
 | 
			
		||||
//UPDATE `tb_topic` SET `Title` = '新标题' WHERE (Id = 1)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 自定义SQL
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
var t10 = update.SetRaw("Title = {0}", "新标题").Where("Id = {0}", 1).ToSql();
 | 
			
		||||
//UPDATE `tb_topic` SET Title = '新标题' WHERE (Id = 1)
 | 
			
		||||
//sql语法条件,参数使用 {0},与 string.Format 保持一致,无须加单引号,错误的用法:'{0}'
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 执行命令
 | 
			
		||||
 | 
			
		||||
| 方法 | 返回值 | 参数 | 描述 |
 | 
			
		||||
| - | - | - | - |
 | 
			
		||||
| ExecuteAffrows | long | | 执行SQL语句,返回影响的行数 |
 | 
			
		||||
| ExecuteUpdated | List\<T1\> | | 执行SQL语句,返回更新后的记录 |
 | 
			
		||||
@@ -1,2 +0,0 @@
 | 
			
		||||
/** layui-v2.2.3 MIT License By http://www.layui.com */
 | 
			
		||||
 html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none}
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 5.8 KiB  | 
| 
		 Before Width: | Height: | Size: 11 KiB  | 
| 
		 Before Width: | Height: | Size: 5.7 KiB  | 
| 
		 Before Width: | Height: | Size: 701 B  | 
| 
		 Before Width: | Height: | Size: 1.7 KiB  | 
| 
		 Before Width: | Height: | Size: 222 KiB  | 
| 
		 Before Width: | Height: | Size: 2.6 KiB  | 
| 
		 Before Width: | Height: | Size: 5.4 KiB  | 
| 
		 Before Width: | Height: | Size: 2.7 KiB  | 
| 
		 Before Width: | Height: | Size: 4.0 KiB  | 
| 
		 Before Width: | Height: | Size: 3.3 KiB  | 
| 
		 Before Width: | Height: | Size: 7.3 KiB  | 
| 
		 Before Width: | Height: | Size: 2.3 KiB  | 
| 
		 Before Width: | Height: | Size: 1.8 KiB  | 
| 
		 Before Width: | Height: | Size: 6.6 KiB  | 
| 
		 Before Width: | Height: | Size: 4.3 KiB  | 
| 
		 Before Width: | Height: | Size: 2.9 KiB  | 
| 
		 Before Width: | Height: | Size: 3.0 KiB  | 
| 
		 Before Width: | Height: | Size: 3.1 KiB  | 
| 
		 Before Width: | Height: | Size: 5.0 KiB  | 
| 
		 Before Width: | Height: | Size: 5.1 KiB  | 
| 
		 Before Width: | Height: | Size: 9.6 KiB  | 
| 
		 Before Width: | Height: | Size: 3.7 KiB  | 
| 
		 Before Width: | Height: | Size: 7.9 KiB  | 
| 
		 Before Width: | Height: | Size: 3.1 KiB  | 
| 
		 Before Width: | Height: | Size: 3.2 KiB  | 
| 
		 Before Width: | Height: | Size: 4.3 KiB  | 
| 
		 Before Width: | Height: | Size: 2.7 KiB  | 
| 
		 Before Width: | Height: | Size: 4.7 KiB  | 
| 
		 Before Width: | Height: | Size: 3.9 KiB  | 
| 
		 Before Width: | Height: | Size: 2.5 KiB  | 
| 
		 Before Width: | Height: | Size: 2.0 KiB  | 
| 
		 Before Width: | Height: | Size: 3.4 KiB  | 
| 
		 Before Width: | Height: | Size: 2.4 KiB  | 
| 
		 Before Width: | Height: | Size: 3.6 KiB  | 
| 
		 Before Width: | Height: | Size: 1.8 KiB  | 
| 
		 Before Width: | Height: | Size: 2.3 KiB  | 
| 
		 Before Width: | Height: | Size: 1.5 KiB  | 
| 
		 Before Width: | Height: | Size: 3.5 KiB  | 
| 
		 Before Width: | Height: | Size: 6.3 KiB  | 
| 
		 Before Width: | Height: | Size: 5.6 KiB  | 
| 
		 Before Width: | Height: | Size: 3.1 KiB  | 
| 
		 Before Width: | Height: | Size: 3.6 KiB  | 
| 
		 Before Width: | Height: | Size: 5.2 KiB  | 
| 
		 Before Width: | Height: | Size: 2.6 KiB  | 
| 
		 Before Width: | Height: | Size: 4.0 KiB  | 
| 
		 Before Width: | Height: | Size: 3.3 KiB  | 
| 
		 Before Width: | Height: | Size: 2.9 KiB  | 
| 
		 Before Width: | Height: | Size: 2.3 KiB  | 
| 
		 Before Width: | Height: | Size: 2.6 KiB  | 
| 
		 Before Width: | Height: | Size: 2.3 KiB  | 
| 
		 Before Width: | Height: | Size: 4.5 KiB  | 
| 
		 Before Width: | Height: | Size: 5.7 KiB  | 
| 
		 Before Width: | Height: | Size: 2.7 KiB  | 
| 
		 Before Width: | Height: | Size: 777 B  | 
| 
		 Before Width: | Height: | Size: 2.1 KiB  | 
| 
		 Before Width: | Height: | Size: 2.1 KiB  | 
| 
		 Before Width: | Height: | Size: 1.9 KiB  | 
| 
		 Before Width: | Height: | Size: 2.0 KiB  | 
| 
		 Before Width: | Height: | Size: 2.6 KiB  | 
| 
		 Before Width: | Height: | Size: 2.2 KiB  | 
| 
		 Before Width: | Height: | Size: 10 KiB  | 
| 
		 Before Width: | Height: | Size: 2.2 KiB  | 
| 
		 Before Width: | Height: | Size: 3.2 KiB  | 
| 
		 Before Width: | Height: | Size: 2.4 KiB  | 
| 
		 Before Width: | Height: | Size: 2.0 KiB  | 
| 
		 Before Width: | Height: | Size: 5.7 KiB  | 
| 
		 Before Width: | Height: | Size: 6.3 KiB  | 
| 
		 Before Width: | Height: | Size: 3.5 KiB  | 
| 
		 Before Width: | Height: | Size: 3.0 KiB  |