コード例 #1
0
        static void Main(string[] args)
        {
            var freesql = new FreeSql.FreeSqlBuilder()
                          .UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456; Database=test;Pooling=true;Minimum Pool Size=1")
                          .Build();

            //初始化扫描
            TableInfomation.Initialize(freesql, typeof(Test), typeof(Test2), typeof(Test3));

            //配置 Join 关系
            //OrmNavigate<Test>.Connect<Test2>(item => item.Domain, item => item.Id);
            //OrmNavigate<Test>.Connect<Test3>(item => item.Type, item => item.Id);

            //前端准备查询条件
            QueryModel queryModel = new QueryModel();

            queryModel.Size   = 2;
            queryModel.Orders = new OrderModel[] { new OrderModel()
                                                   {
                                                       FieldName = "Id", IsDesc = true
                                                   } };
            //queryModel.Fuzzy = new FuzzyModel[] { new FuzzyModel {  FuzzyField = "Name", FuzzyValue = "44" } };

            //外联查询
            Console.ReadKey();
        }
コード例 #2
0
 public static IServiceCollection AddAriesAssembly(this IServiceCollection services, Assembly assembly)
 {
     if (FreeSqlHandler == default)
     {
         throw new System.Exception("请优先注册 AriesFreeSql : services.AddAriesFreeSql(type,conn)");
     }
     TableInfomation.InitializeAssembly(FreeSqlHandler, assembly);
     return(services);
 }
コード例 #3
0
 public static IServiceCollection AddAriesEntities(this IServiceCollection services, params Type[] types)
 {
     if (FreeSqlHandler == default)
     {
         throw new System.Exception("请优先注册 AriesFreeSql : services.AddAriesFreeSql(type,conn)");
     }
     TableInfomation.InitializeTypes(FreeSqlHandler, types);
     return(services);
 }
コード例 #4
0
 public static IServiceCollection AddAriesFreeSql(this IServiceCollection services, DataType sqlType, string connectionString, Action <IFreeSql> callBack = null)
 {
     FreeSqlHandler = new FreeSql.FreeSqlBuilder()
                      .UseConnectionString(sqlType, connectionString)
                      .Build();
     callBack?.Invoke(FreeSqlHandler);
     services.AddSingleton(FreeSqlHandler);
     TableInfomation.InitializeTypes(FreeSqlHandler, typeof(AriesOptimisticLockModel));
     return(services);
 }
コード例 #5
0
 public ServiceResult GetTableInfomation([FromBody] ZzbHomeGetTableInfomationViewModel model)
 {
     return(Json(() =>
     {
         if (!NavTrees.IsExistPermission(UserId, model.NavId))
         {
             HttpContext.Response.StatusCode = 403;
             return null;
         }
         return ObjectResult(TableInfomation.GetTableInfomation(model.NavId));
     }, "获取表单信息失败"));
 }
コード例 #6
0
        public ServiceResult HandleAction(ZzbHomeHandleViewActionViewModel model)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            foreach (var k in model.Data.Keys)
            {
                if (model.Data[k] != null)
                {
                    JsonElement jsonEle = (JsonElement)model.Data[k];

                    if (jsonEle.ValueKind == JsonValueKind.Array)
                    {
                        var list = jsonEle.EnumerateArray().ToList();
                        var str  = "";
                        foreach (var item in list)
                        {
                            str += item.ToString() + ",";
                        }
                        if (str.Length > 0)
                        {
                            str = str.Substring(0, str.Length - 1);
                        }

                        dic.Add(k, str);
                    }
                    else
                    {
                        dic.Add(k, model.Data[k]?.ToString());
                    }
                }
                else
                {
                    dic.Add(k, model.Data[k]?.ToString());
                }
            }
            return(Json(
                       () => TableInfomation.HandleModalAction(model.ModalId, model.ButtonId,
                                                               dic), "执行action方法失败"));
        }
コード例 #7
0
 public ServiceResult HandleRowAction(ZzbHomeHandleRowActionViewModel model)
 {
     return(Json(() => TableInfomation.HandleNavAction(model.NavId, model.ButtonId, model.Data), "执行Row按钮失败"));
 }
コード例 #8
0
 public ServiceResult GetModalInfo(ZzbHomeGetViewsModalInfoViewModel model)
 {
     return(Json(() => ObjectResult(TableInfomation.GetButtonModalInfo(model.ModalId, model.Data)),
                 "获取按钮信息失败"));
 }