/// <summary>
        /// 创建代码
        /// </summary>
        public void Create_Code()
        {
            #region folders

            string template_folder = context.Server.MapPath(settings.folder_templates + settings.template_folder_domain_models_identities);
            string template_file   = template_folder + "{{entity_sub_namespace}}ID.cs";

            string target_folder = template_folder.Replace(context.Server.MapPath(settings.folder_templates), context.Server.MapPath(settings.folder_result));
            string target_file   = template_file.Replace(context.Server.MapPath(settings.folder_templates), context.Server.MapPath(settings.folder_result));

            target_folder = target_folder.Replace("{{namespace}}", settings.code_namespace);
            target_folder = target_folder.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            target_file = target_file.Replace("{{namespace}}", settings.code_namespace);
            target_file = target_file.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            #endregion

            string template = FileHelper.ReadAll(template_file);

            template = template.Replace("{{namespace}}", settings.code_namespace);
            template = template.Replace("{{entity_name}}", entity_name);
            template = template.Replace("{{entity_sub_namespace}}", entity_sub_namespace);
            template = template.Replace("{{domain_model_name}}", NameHelper.Get_Domain_Model_Name(entity_name));
            template = template.Replace("{{domain_model_id_name}}", NameHelper.Get_Identities_Name(entity_name));


            FileHelper.CheckAndCreateFolder(target_folder);
            FileHelper.WriteAll(target_file, template);
        }
        /// <summary>
        /// 创建代码
        /// </summary>
        public void Create_Code()
        {
            #region folders

            string template_folder = context.Server.MapPath(settings.folder_templates + settings.template_folder_data_access_query_interface);
            string template_file   = template_folder + "I{{entity_sub_namespace}}QueryDataAccessor.cs";

            string target_folder = template_folder.Replace(context.Server.MapPath(settings.folder_templates), context.Server.MapPath(settings.folder_result));
            string target_file   = template_file.Replace(context.Server.MapPath(settings.folder_templates), context.Server.MapPath(settings.folder_result));

            target_folder = target_folder.Replace("{{namespace}}", settings.code_namespace);
            target_folder = target_folder.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            target_file = target_file.Replace("{{namespace}}", settings.code_namespace);
            target_file = target_file.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            #endregion

            string template = FileHelper.ReadAll(template_file);

            template = template.Replace("{{namespace}}", settings.code_namespace);
            template = template.Replace("{{entity_name}}", entity_name);
            template = template.Replace("{{entity_sub_namespace}}", entity_sub_namespace);
            template = template.Replace("{{domain_model_name}}", NameHelper.Get_Domain_Model_Name(entity_name));
            template = template.Replace("{{domain_model_id_name}}", NameHelper.Get_Identities_Name(entity_name));


            template = template.Replace("{{get_details_method_name}}", NameHelper.Get_MethodName_QueryService_GetDetails_Name(entity_name));
            template = template.Replace("{{list_method_name}}", NameHelper.Get_MethodName_QueryService_GetList_Name(entity_name));
            template = template.Replace("{{list_parameters_model_name}}", NameHelper.Get_ViewModel_Query_ListParameter_Name(entity_name));


            FileHelper.CheckAndCreateFolder(target_folder);
            FileHelper.WriteAll(target_file, template);
        }
        public void Create_Batch_DeleteCommand_Command()
        {
            #region folders

            string template_folder = context.Server.MapPath(settings.folder_templates + settings.template_folder_command_handlers);
            string template_file   = template_folder + "BatchDeleteCommandHander.cs";

            string target_folder = template_folder.Replace(context.Server.MapPath(settings.folder_templates), context.Server.MapPath(settings.folder_result));
            string target_file   = template_file.Replace(context.Server.MapPath(settings.folder_templates), context.Server.MapPath(settings.folder_result));

            target_folder = target_folder.Replace("{{namespace}}", settings.code_namespace);
            target_folder = target_folder.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            target_file = target_file.Replace("{{namespace}}", settings.code_namespace);
            target_file = target_file.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            #endregion

            string template = FileHelper.ReadAll(template_file);

            template = template.Replace("{{namespace}}", settings.code_namespace);
            template = template.Replace("{{entity_name}}", entity_name);
            template = template.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            template = template.Replace("{{domain_model_id_name}}", NameHelper.Get_Identities_Name(entity_name));
            template = template.Replace("{{batch_delete_method_name}}", NameHelper.Get_MethodName_DataAccess_Domain_BatchDelete(entity_name));

            FileHelper.CheckAndCreateFolder(target_folder);
            FileHelper.WriteAll(target_file, template);
        }
        private string Create_Controller_Code_Details(string template)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("        /// <summary>");
            sb.AppendLine("        /// Get " + entity_name + " detail");
            sb.AppendLine("        /// </summary>");
            sb.AppendLine("        /// <param name=\"id\"></param>");
            sb.AppendLine("        /// <returns></returns>");
            sb.AppendLine("        [Route(\"api/" + entity_sub_namespace + "/Details\")]");
            sb.AppendLine("        [PermissionVerify(CommonEnum.Operations.Read)]");
            sb.AppendLine("        [HttpGet]");
            sb.AppendLine("        public IHttpActionResult Get(Guid modelId)");
            sb.AppendLine("        {");
            sb.AppendLine("            " + NameHelper.Get_Identities_Name(entity_name) + " " + entity_id_properties.Name.ToString() + " = new " + NameHelper.Get_Identities_Name(entity_name) + "(modelId);");
            sb.AppendLine("            var queryResult = QueryService." + NameHelper.Get_MethodName_QueryService_GetDetails_Name(entity_name) + "(" + entity_id_properties.Name.ToString() + ");");
            sb.AppendLine("            if (queryResult != null)");
            sb.AppendLine("            {");
            sb.AppendLine("                return Json(queryResult);");
            sb.AppendLine("            }");
            sb.AppendLine("            return Json(string.Empty);");
            sb.Append("        }");

            template = template.Replace("{{Details-Actions}}", sb.ToString());
            return(template);
        }
Beispiel #5
0
        private string Create_Get_Entity_Code(string template)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("        /// <summary>");
            sb.AppendLine("        /// Get " + entity_name + " entity");
            sb.AppendLine("        /// </summary>");
            sb.AppendLine("        /// <param name=\"domain_object\"></param>");
            sb.AppendLine("        private " + entity_name + " GetEntity(" + NameHelper.Get_Identities_Name(entity_name) + " id)");
            sb.AppendLine("        {");
            sb.AppendLine("            var entity_id = GetPersistId<Guid>(id);");
            sb.AppendLine("            return GetQuery<" + entity_name + ">().FirstOrDefault(x => x." + this.entity_id_properties.Name + " == entity_id);");
            sb.Append("        }");

            template = template.Replace("{{Get-Entity-Method}}", sb.ToString());

            return(template);
        }
        /// <summary>
        /// 创建代码
        /// </summary>
        public void Create_Code()
        {
            #region folders

            string template_folder = context.Server.MapPath(settings.folder_templates + settings.template_folder_data_access_domain_interface);
            string template_file   = template_folder + "I{{entity_sub_namespace}}DataAccessor.cs";

            string target_folder = template_folder.Replace(context.Server.MapPath(settings.folder_templates), context.Server.MapPath(settings.folder_result));
            string target_file   = template_file.Replace(context.Server.MapPath(settings.folder_templates), context.Server.MapPath(settings.folder_result));

            target_folder = target_folder.Replace("{{namespace}}", settings.code_namespace);
            target_folder = target_folder.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            target_file = target_file.Replace("{{namespace}}", settings.code_namespace);
            target_file = target_file.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            #endregion

            string template = FileHelper.ReadAll(template_file);

            template = template.Replace("{{namespace}}", settings.code_namespace);
            template = template.Replace("{{entity_name}}", entity_name);
            template = template.Replace("{{entity_sub_namespace}}", entity_sub_namespace);
            template = template.Replace("{{domain_model_name}}", NameHelper.Get_Domain_Model_Name(entity_name));
            template = template.Replace("{{domain_model_id_name}}", NameHelper.Get_Identities_Name(entity_name));


            template = template.Replace("{{add_return_name}}", entity_name);
            template = template.Replace("{{add_method_name}}", NameHelper.Get_MethodName_DataAccess_Domain_Add(entity_name));
            template = template.Replace("{{upate_method_name}}", NameHelper.Get_MethodName_DataAccess_Domain_Update(entity_name));
            template = template.Replace("{{delete_method_name}}", NameHelper.Get_MethodName_DataAccess_Domain_Delete(entity_name));
            template = template.Replace("{{batch_delete_method_name}}", NameHelper.Get_MethodName_DataAccess_Domain_BatchDelete(entity_name));

            FileHelper.CheckAndCreateFolder(target_folder);
            FileHelper.WriteAll(target_file, template);
        }
        public void Create_Update_Command_Custom()
        {
            #region folders
            string template_folder = context.Server.MapPath(settings.folder_templates + settings.template_folder_command_handlers);
            string template_file   = template_folder + "UpdateCommandHander_Custom.cs";

            string target_folder = template_folder.Replace(context.Server.MapPath(settings.folder_templates), context.Server.MapPath(settings.folder_result));
            string target_file   = template_file.Replace(context.Server.MapPath(settings.folder_templates), context.Server.MapPath(settings.folder_result));

            target_folder = target_folder.Replace("{{namespace}}", settings.code_namespace);
            target_folder = target_folder.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            target_file = target_file.Replace("{{namespace}}", settings.code_namespace);
            target_file = target_file.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            #endregion
            string template = FileHelper.ReadAll(template_file);

            template = template.Replace("{{namespace}}", settings.code_namespace);
            template = template.Replace("{{entity_name}}", entity_name);
            template = template.Replace("{{entity_sub_namespace}}", entity_sub_namespace);
            //template = template.Replace("{{domain_model_id_name}}", NameHelper.Get_Identities_Name(entity_name));
            //template = template.Replace("{{update_method_name}}", NameHelper.Get_MethodName_DataAccess_Domain_Update(entity_name));

            StringBuilder sb = new StringBuilder();

            #region Exec_Command_Code
            sb.AppendLine("            DomainModels." + NameHelper.Get_Domain_Model_Name(entity_name) + " data = new DomainModels." + NameHelper.Get_Domain_Model_Name(entity_name) + "()");
            sb.AppendLine("            {");
            sb.AppendLine("                " + NameHelper.Get_Property_Name_For_DomainModels(entity_id_properties.Name) + " = new " + NameHelper.Get_Identities_Name(entity_name) + "(command." + NameHelper.Get_Property_Name_For_Command(entity_id_properties.Name) + "),");
            foreach (var p in entity_properties.Where(x => x.Name != entity_id_properties.Name).ToList())
            {
                sb.AppendLine("                " + NameHelper.Get_Property_Name_For_DomainModels(p.Name) + " = command." + NameHelper.Get_Property_Name_For_Command(p.Name) + ",");
            }
            sb.AppendLine("            };");
            sb.AppendLine("            DataAccessor." + NameHelper.Get_MethodName_DataAccess_Domain_Update(entity_name) + "(data);");
            sb.AppendLine("            if (!needTransaction)");
            sb.AppendLine("            {");
            sb.AppendLine("                 DataAccessor.Save();");
            sb.AppendLine("             }");
            sb.AppendLine("            command.ExecuteSuccess(data." + NameHelper.Get_Property_Name_For_DomainModels(entity_id_properties.Name) + ");");

            template = template.Replace("{{Exec_Command_Code}}", sb.ToString());
            #endregion

            #region Validate
            sb = new StringBuilder();

            sb.AppendLine("            var result = new List<BusinessError>();");

            sb.AppendLine("            //---------------------------------------");
            sb.AppendLine("            //Rules");
            sb.AppendLine("            //---------------------------------------");

            foreach (var p in entity_properties)
            {
                switch (p.PropertyType.Name)
                {
                case "String":
                    sb.AppendLine("            if (string.IsNullOrWhiteSpace(command." + NameHelper.Get_Property_Name_For_Command(p.Name) + "))");
                    sb.AppendLine("            {");
                    sb.AppendLine("                result.Add(ErrorFactory.CreateFieldIsRequiredError(\"" + NameHelper.Get_Property_Name_For_Command(p.Name) + "\", \"" + NameHelper.Get_Property_Name_For_DisplayInErrorMessage_DomainModel(p.Name) + " is required!\"));");
                    sb.AppendLine("            }");
                    break;

                case "DateTime":
                    if (p.Nullable)
                    {
                        sb.AppendLine("            if (command." + NameHelper.Get_Property_Name_For_Command(p.Name) + ".HasValue() && !command." + NameHelper.Get_Property_Name_For_Command(p.Name) + ".Value.IsValid())");
                    }
                    else
                    {
                        sb.AppendLine("            if (!command." + NameHelper.Get_Property_Name_For_Command(p.Name) + ".IsValid())");
                    }
                    sb.AppendLine("            {");
                    sb.AppendLine("                result.Add(ErrorFactory.CreateFieldIsRequiredError(\"" + NameHelper.Get_Property_Name_For_Command(p.Name) + "\", \"" + NameHelper.Get_Property_Name_For_DisplayInErrorMessage_DomainModel(p.Name) + " is invalid!\"));");
                    sb.AppendLine("            }");
                    break;

                case "Guid":
                    if (p.Nullable)
                    {
                        sb.AppendLine("            if (command." + NameHelper.Get_Property_Name_For_Command(p.Name) + ".HasValue() && !command." + NameHelper.Get_Property_Name_For_Command(p.Name) + ".Value == Guid.Empty)");
                    }
                    else
                    {
                        sb.AppendLine("            if (command." + NameHelper.Get_Property_Name_For_Command(p.Name) + " == Guid.Empty)");
                    }
                    sb.AppendLine("            {");
                    sb.AppendLine("                result.Add(ErrorFactory.CreateFieldIsRequiredError(\"" + NameHelper.Get_Property_Name_For_Command(p.Name) + "\", \"" + NameHelper.Get_Property_Name_For_DisplayInErrorMessage_DomainModel(p.Name) + " is required!\"));");
                    sb.AppendLine("            }");
                    break;
                }
            }

            sb.AppendLine("            //---------------------------------------");
            sb.AppendLine("            //Other rules");
            sb.AppendLine("            //---------------------------------------");

            template = template.Replace("{{Validate_Command_Parmeters_Code}}", sb.ToString());
            #endregion

            FileHelper.CheckAndCreateFolder(target_folder);
            FileHelper.WriteAll(target_file, template);
        }
        /// <summary>
        /// 创建代码
        /// </summary>
        public void Create_Code()
        {
            #region folders

            string template_folder = context.Server.MapPath(settings.folder_templates + settings.template_folder_domain_models);
            string template_file   = template_folder + "{{entity_sub_namespace}}.cs";

            string target_folder = template_folder.Replace(context.Server.MapPath(settings.folder_templates), context.Server.MapPath(settings.folder_result));
            string target_file   = template_file.Replace(context.Server.MapPath(settings.folder_templates), context.Server.MapPath(settings.folder_result));

            target_folder = target_folder.Replace("{{namespace}}", settings.code_namespace);
            target_folder = target_folder.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            target_file = target_file.Replace("{{namespace}}", settings.code_namespace);
            target_file = target_file.Replace("{{entity_sub_namespace}}", entity_sub_namespace);

            #endregion

            string template = FileHelper.ReadAll(template_file);

            template = template.Replace("{{namespace}}", settings.code_namespace);
            template = template.Replace("{{entity_name}}", entity_name);
            template = template.Replace("{{entity_sub_namespace}}", entity_sub_namespace);
            template = template.Replace("{{domain_model_name}}", NameHelper.Get_Domain_Model_Name(entity_name));

            #region Create code

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("        public " + NameHelper.Get_Identities_Name(entity_name) + " " + NameHelper.Get_Property_Name_For_DomainModels(entity_id_properties.Name) + " { get; set; }");

            foreach (var p in entity_properties.Where(x => x.Name != entity_id_properties.Name).ToList())
            {
                sb.AppendLine("        public " + NameHelper.GetEntityPropertyTypeString(p) + " " + NameHelper.Get_Property_Name_For_DomainModels(p.Name) + " { get; set; }");
            }
            //sb.AppendLine("");
            sb.AppendLine("        public " + entity_name + " ConvertToEntity()");
            sb.AppendLine("        {");
            sb.AppendLine("            " + entity_name + " entity = new " + entity_name + "();");
            foreach (var p in entity_properties.ToList())
            {
                if (p.Name == entity_id_properties.Name)
                {
                    sb.AppendLine("            entity." + p.Name + " = (Guid)this." + NameHelper.Get_Property_Name_For_DomainModels(p.Name) + ".GetPersistId();");
                }
                else
                {
                    sb.AppendLine("            entity." + p.Name + " = this." + NameHelper.Get_Property_Name_For_DomainModels(p.Name) + ";");
                }
            }

            sb.AppendLine("            return entity;");
            sb.Append("        }");

            template = template.Replace("{{Domain-Model-Parmeters}}", sb.ToString());

            #endregion

            FileHelper.CheckAndCreateFolder(target_folder);
            FileHelper.WriteAll(target_file, template);
        }
        private string Create_Controller_Code_Update(string template)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("        /// <summary>");
            sb.AppendLine("        /// Update a(n) " + entity_name + " details");
            sb.AppendLine("        /// </summary>");
            sb.AppendLine("        /// <returns></returns>");
            sb.AppendLine("        [Route(\"api/" + entity_sub_namespace + "/Put\")]");
            sb.AppendLine("        [PermissionVerify(new CommonEnum.Operations[] { CommonEnum.Operations.Setup })]");
            sb.AppendLine("        [HttpPut]");
            sb.AppendLine("        public IHttpActionResult Put(" + NameHelper.Get_ViewModel_UpdateModel(entity_name) + " model)");
            sb.AppendLine("        {");
            sb.AppendLine("            " + NameHelper.Get_Identities_Name(entity_name) + " " + entity_id_properties.Name.ToString() + " = new " + NameHelper.Get_Identities_Name(entity_name) + "(model.id);");
            sb.AppendLine("            var oldValue = QueryService." + NameHelper.Get_MethodName_QueryService_GetDetails_Name(entity_name) + "(" + entity_id_properties.Name.ToString() + ");");
            sb.AppendLine("            var command = new UpdateCommand()");
            sb.AppendLine("            {");
            foreach (var p in entity_properties)
            {
                if (NameHelper.Get_Property_Name_For_Command(p.Name).Equals("Created_Time") ||
                    NameHelper.Get_Property_Name_For_Command(p.Name).Equals("Created_User_Id") ||
                    NameHelper.Get_Property_Name_For_Command(p.Name).Equals("Last_Updated_Time") ||
                    NameHelper.Get_Property_Name_For_Command(p.Name).Equals("Last_Updated_User_Id"))
                {
                    break;
                }

                if (NameHelper.Get_Property_Name_For_Command(p.Name).Equals("Organization_Id"))
                {
                    sb.AppendLine("                " + NameHelper.Get_Property_Name_For_Command(p.Name) + " = oldValue." + NameHelper.Get_Property_Name_For_ViewModel(p.Name) + ",");
                }
                else
                {
                    sb.AppendLine("                " + NameHelper.Get_Property_Name_For_Command(p.Name) + " = model." + NameHelper.Get_Property_Name_For_ViewModel(p.Name) + ",");
                }
            }
            sb.AppendLine("            };");
            //sb.AppendLine("");
            sb.AppendLine("            command.Created_Time = oldValue.created_time;");
            sb.AppendLine("            command.Created_User_Id = oldValue.created_user_id;");
            sb.AppendLine("            command.Last_Updated_Time = DateTime.Now;");
            sb.AppendLine("            command.Last_Updated_User_Id = WebData.LoginedUser.UserId;");
            //sb.AppendLine("");
            sb.AppendLine("            CommandBus.Send(command);");
            //sb.AppendLine("");
            sb.AppendLine("            var properties = string.Empty;");
            foreach (var p in entity_properties)
            {
                sb.AppendLine("            if(oldValue." + NameHelper.Get_Property_Name_For_ViewModel(p.Name) + " != model." + NameHelper.Get_Property_Name_For_ViewModel(p.Name) + ")");
                sb.AppendLine("            {");
                sb.AppendLine("                 properties += \"" + NameHelper.Get_Property_Name_For_ViewModel(p.Name) + ";\";");
                sb.AppendLine("            }");
            }

            //sb.AppendLine("");
            sb.AppendLine("            if (!properties.IsNullOrEmpty()) { properties.Substring(0, properties.Length - 1); }");
            //sb.AppendLine("");
            sb.AppendLine("            if (NeedRecordSystemLog(Operations.Update)) ");
            sb.AppendLine("            {");
            sb.AppendLine("                 RecordSystemLog(JsonConvert.SerializeObject(command), null, properties, Operations.Delete);");
            sb.AppendLine("            }");

            sb.AppendLine("            return CommandResult(command.ExecuteResult);");
            sb.Append("        }");

            template = template.Replace("{{Update-Actions}}", sb.ToString());
            return(template);
        }
Beispiel #10
0
        private string Create_GetDetails_Code(string template)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("        /// <summary>");
            sb.AppendLine("        /// Get " + entity_name + " domain model");
            sb.AppendLine("        /// </summary>");
            sb.AppendLine("        /// <param name=\"id\"></param> ");
            sb.AppendLine("        /// <returns></returns>");
            sb.AppendLine("        public DetailsModel " + NameHelper.Get_MethodName_DataAccess_Query_GetDetails_Name(entity_name) + "(" + NameHelper.Get_Identities_Name(entity_name) + " id)");
            sb.AppendLine("        {");
            sb.AppendLine("            var entity = GetEntity(id);");
            sb.AppendLine("            if (entity == null)");
            sb.AppendLine("            {");
            sb.AppendLine("                return null;");
            sb.AppendLine("            }");
            sb.AppendLine("            else");
            sb.AppendLine("            {");
            sb.AppendLine("                return new DetailsModel()");
            sb.AppendLine("                {");
            foreach (var p in entity_properties)
            {
                //sb.AppendLine("");
                sb.AppendLine("                    " + NameHelper.Get_Property_Name_For_Query_DetailsModel(p.Name) + " = entity." + p.Name + ",");
            }
            sb.AppendLine("                };");
            sb.AppendLine("            }");
            sb.AppendLine("        }");

            template = template.Replace("{{Get-Details-Method}}", sb.ToString());

            return(template);
        }
        private string Create_Delete_Code(string template)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("        /// <summary>");
            sb.AppendLine("        /// Delete a(n) " + entity_name);
            sb.AppendLine("        /// </summary>");
            sb.AppendLine("        /// <param name=\"id\"></param>");
            sb.AppendLine("        public void " + NameHelper.Get_MethodName_DataAccess_Domain_Delete(entity_name) + "(" + NameHelper.Get_Identities_Name(entity_name) + " id)");
            sb.AppendLine("        {");

            sb.AppendLine("            var entity = GetEntity(id);");
            sb.AppendLine("            if (entity != null)");
            sb.AppendLine("            {");
            sb.AppendLine("                GetDbSet<" + entity_name + ">().Remove(entity);");
            sb.AppendLine("            }");

            sb.Append("        }");

            template = template.Replace("{{Delete-Method}}", sb.ToString());

            return(template);
        }
        private string Create_Convert_To_Domain_Model_Code(string template)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("        /// <summary>");
            sb.AppendLine("        /// Convert entity to domain model");
            sb.AppendLine("        /// </summary>");
            sb.AppendLine("        /// <param name=\"entity\"></param>");
            sb.AppendLine("        /// <returns></returns>");
            sb.AppendLine("        private static " + NameHelper.Get_Domain_Model_Name(entity_name) + " ConvertTo" + NameHelper.Get_Domain_Model_Name(entity_name) + "(" + entity_name + " entity)");
            sb.AppendLine("        {");
            sb.AppendLine("            return new " + NameHelper.Get_Domain_Model_Name(entity_name) + "()");
            sb.AppendLine("            {");
            sb.AppendLine("                " + NameHelper.Get_Property_Name_For_DomainModels(this.entity_id_properties.Name) + " = new " + NameHelper.Get_Identities_Name(entity_name) + "(entity." + this.entity_id_properties.Name + "),");
            foreach (var p in entity_properties.Where(x => x.Name != entity_id_properties.Name).ToList())
            {
                //sb.AppendLine("");
                sb.AppendLine("                " + NameHelper.Get_Property_Name_For_DomainModels(p.Name) + " = entity." + p.Name + ",");
            }
            sb.AppendLine("            };");
            sb.Append("        }");

            template = template.Replace("{{Convert-To-Domain-Model-Method}}", sb.ToString());

            return(template);
        }
        private string Create_Batch_Delete_Code(string template)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("        /// <summary>");
            sb.AppendLine("        /// Delete a(n) " + entity_name);
            sb.AppendLine("        /// </summary>");
            sb.AppendLine("        /// <param name=\"id\"></param>");
            sb.AppendLine("        public void " + NameHelper.Get_MethodName_DataAccess_Domain_BatchDelete(entity_name) + "(" + NameHelper.Get_Identities_Name(entity_name) + "[] ids)");
            sb.AppendLine("        {");

            sb.AppendLine("             var entity_ids = ids.Select(x => (Guid)x.GetPersistId()).ToArray();");
            sb.AppendLine("             var entities = GetDbSet<" + entity_name + ">().Where(x => entity_ids.Contains(x.id));");
            sb.AppendLine("             GetDbSet<" + entity_name + ">().RemoveRange(entities);");
            //sb.AppendLine("             foreach (var item in entities)");
            //sb.AppendLine("             {");
            //sb.AppendLine("                 GetDbSet<" + entity_name + ">().Remove(item);");
            //sb.AppendLine("             }");

            sb.Append("        }");

            template = template.Replace("{{Batch-Delete-Method}}", sb.ToString());

            return(template);
        }