public override void Render()
 {
     if (ToPropertyName().ToLower() == _script.Settings.DataOptions.VersionColumnName.ToLower())
     {
         _output.autoTabLn("public string " + this.Alias + " { get; set; }");
     }
     else
     {
         _output.tabLevel++;
         _output.autoTabLn("public " + LanguageType + " " + ToPropertyName());
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("get");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("return this._" + StringFormatter.CamelCasing(LanguageType) + ";");
         _output.tabLevel--;
         _output.autoTabLn("}");
         _output.autoTabLn("set");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("this._" + StringFormatter.CamelCasing(LanguageType) + " = value;");
         _output.tabLevel--;
         _output.autoTabLn("}");
         _output.tabLevel--;
         _output.autoTabLn("}");
     }
 }
        public void Interface(ITable table)
        {
            string   tableName = table.Name;
            string   args      = "";
            GenTable genTable  = new GenTable(table, _context);
            string   str       = "";

            str += _util.BuildModelClassWithNameSpace(tableName) + " GetById(";

            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                // type + " " + key name
                args += genTable.GetPrimaryKeyTypes[i] + " ";
                args += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
            }
            // trim the trailing ", "

            args = args.Substring(0, (args.Length - 2));

            str += args;
            str += ");";
            _output.tabLevel++;
            _output.tabLevel++;
            _output.autoTabLn(str);
            _output.tabLevel--;
            _output.tabLevel--;

            str  = "";
            str += "List<" + _util.BuildModelClassWithNameSpace(tableName) + "> GetAll(string sortExpression, int startRowIndex, int maximumRows);";
            _output.tabLevel++;
            _output.tabLevel++;
            _output.autoTabLn(str);
            _output.tabLevel--;
            _output.tabLevel--;
        }
        private void RenderConcreteClass(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Linq;");
            _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces;");
            _output.autoTabLn("using " + _script.Settings.ServiceLayer.ServiceNamespace + ".Generated;");
            _output.autoTabLn("using " + _script.Settings.ServiceLayer.ServiceNamespace + ".Interfaces;");
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace);
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public class " + StringFormatter.CleanUpClassName(table.Name) + "Service : " + StringFormatter.CleanUpClassName(table.Name) + "ServiceBase, I" + StringFormatter.CleanUpClassName(table.Name) + "Service");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + "Service(I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ")");
            _output.tabLevel++;
            _output.autoTabLn(": base(" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ")");
            _output.tabLevel--;
            _output.autoTabLn("{");
            _output.autoTabLn("");
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + "Service.cs");
            SaveOutput(CreateFullPath(_script.Settings.ServiceLayer.ServiceNamespace, StringFormatter.CleanUpClassName(table.Name) + "Service.cs"), SaveActions.DontOverwrite);
        }
        public void Update(ITable table)
        {
            string tableName = table.Name;

            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// Update " + StringFormatter.CleanUpClassName(tableName) + ".  Map  fields to " + StringFormatter.CleanUpClassName(tableName) + " properties.");
            _output.autoTabLn("/// </summary>");
            _output.autoTabLn("/// <param name=\"" + StringFormatter.CleanUpClassName(tableName) + "\"></param>");
            _output.autoTabLn("/// <returns></returns>");
            _output.autoTabLn("public void Update(" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " model)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn(StringFormatter.CleanUpClassName(tableName) + " entity = new " + StringFormatter.CleanUpClassName(tableName) + "();");

            GenTable genTable = new GenTable(table, _context);
            string   args     = "";
            string   keys     = "";
            string   types    = "";

            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                // type + " " + key name
                args  += genTable.GetPrimaryKeyTypes[i] + " ";
                args  += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
                keys  += StringFormatter.PascalCasing(genTable.GetPrimaryKeyNames[i]) + ",";
                types += genTable.GetPrimaryKeyTypes[i] + ",";
            }
            // trim the trailing ", "
            args  = args.Substring(0, (args.Length - 2));
            keys  = keys.Substring(0, (keys.Length - 1));
            types = types.Substring(0, (types.Length - 1));

            _output.autoTabLn("if (entity.LoadByPrimaryKey(model." + keys + "))");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("entity = model.ToEntity(entity);");
            _output.autoTabLn("entity.Save();");
            _output.autoTabLn("");

            string[] keysSplit  = keys.Split(',');
            string[] argsSplit  = args.Split(',');
            string[] typesSplit = types.Split(',');
            int      counter    = 0;

            foreach (string key in keysSplit)
            {
                _output.autoTabLn("model." + key.Trim() + " = (" + typesSplit[counter] + ")entity." + key.Trim() + ";");
                counter++;
            }

            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.tabLevel--;
        }
Пример #5
0
        public void GetById(MyMeta.ITable table)
        {
            string args      = string.Empty;
            string keys      = string.Empty;
            string tableName = table.Name;

            GenTable genTable = new GenTable(table, _context);

            _output.tabLevel++;
            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// GetById and map the fields to the Model.");
            _output.autoTabLn("/// </summary>");
            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                _output.autoTabLn("/// <param name=\"" + StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + "\"></param>");
            }

            _output.autoTabLn("/// <returns></returns>");
            _output.autoTab("public " + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " GetById(");
            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                // type + " " + key name
                args += genTable.GetPrimaryKeyTypes[i] + " ";
                args += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
                keys += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
            }
            // trim the trailing ", "
            args = args.Substring(0, (args.Length - 2));
            keys = keys.Substring(0, (keys.Length - 2));
            _output.write(args);
            _output.writeln(")");
            _output.autoTabLn("{");

            _output.tabLevel++;
            _output.autoTabLn("using (var context = DataContextFactory.CreateContext())");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("return " + StringFormatter.CleanUpClassName(tableName) + "Mapper.ToBusinessObject(context." + StringFormatter.MakePlural(StringFormatter.CleanUpClassName(tableName)));
            string[] keysSplit = keys.Split(',');
            foreach (string key in keysSplit)
            {
                _output.tabLevel++;
                _output.autoTabLn(".Where(o => o." + _util.CleanUpProperty(key) + " == " + key + ")");
            }
            _output.autoTabLn(".SingleOrDefault());");
            _output.tabLevel--;
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.tabLevel--;
        }
        public void Update(ITable table)
        {
            _output.tabLevel++;
            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// Update " + StringFormatter.CleanUpClassName(table.Name) + ".  Map  fields to " + StringFormatter.CleanUpClassName(table.Name) + " properties.");
            _output.autoTabLn("/// </summary>");
            _output.autoTabLn("/// <param name=\"" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + "\"></param>");
            _output.autoTabLn("/// <returns></returns>");
            _output.autoTabLn("public void Update(" + _context.Utility.BuildModelClassWithNameSpace(table.Name) + " model)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("");
            _output.autoTabLn("using (var context = DataObjectFactory.CreateContext())");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("");
            _output.autoTabLn("var entity = context." + StringFormatter.CleanUpClassName(table.Name, true));

            GenTable genTable = new GenTable(table, _context);

            _output.tabLevel++;
            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                _output.autoTabLn(".Where(o => o." + genTable.GetPrimaryKeyNames[i] + " == model." + genTable.GetPrimaryKeyNames[i] + ")");
            }

            _output.autoTabLn(".SingleOrDefault();");

            _output.tabLevel--;
            _output.autoTabLn("entity = model.ToEntity(entity);");
            _output.autoTabLn("");
            _output.autoTabLn("try");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("context.SaveChanges();");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("catch (OptimisticConcurrencyException)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("context.Refresh(System.Data.Objects.RefreshMode.ClientWins, entity);");
            _output.autoTabLn("context.SaveChanges();");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.tabLevel--;
        }
        public void GetById(ITable table)
        {
            string tableName = table.Name;
            string args      = string.Empty;
            string keys      = string.Empty;

            GenTable genTable = new GenTable(table, _context);

            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// GetById and map the fields to the Model.");
            _output.autoTabLn("/// </summary>");
            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                _output.autoTabLn("/// <param name=\"" + StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + "\"></param>");
            }
            _output.autoTabLn("/// <returns></returns>");
            _output.autoTab("public " + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " GetById(");
            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                // type + " " + key name
                args += genTable.GetPrimaryKeyTypes[i] + " ";
                args += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
                keys += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
            }
            // trim the trailing ", "
            args = args.Substring(0, (args.Length - 2));
            keys = keys.Substring(0, (keys.Length - 2));
            _output.write(args.Trim());
            _output.writeln(")");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn(_util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " model = null;");
            _output.autoTabLn(StringFormatter.CleanUpClassName(tableName) + " entity = new " + StringFormatter.CleanUpClassName(tableName) + "();");

            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                _output.autoTabLn("if (entity.LoadByPrimaryKey(" + StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + "))");
            }
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("model = entity.ToBusinessObject();");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.autoTabLn("return model;");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.tabLevel--;
        }
Пример #8
0
        private void RenderConcreteClass(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Linq;");
            _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
            _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces;");
            _output.autoTabLn("using " + _script.Settings.ServiceLayer.ServiceNamespace + ".Generated;");
            _output.autoTabLn("using " + _script.Settings.ServiceLayer.ServiceNamespace + ".Interfaces;");
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace);
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public class " + StringFormatter.CleanUpClassName(table.Name) + "Service : ServiceBase<" + StringFormatter.CleanUpClassName(table.Name) + ", I" + StringFormatter.CleanUpClassName(table.Name) + "Dao>, I" + StringFormatter.CleanUpClassName(table.Name) + "Service");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + "Service(I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ")");
            _output.tabLevel++;
            _output.autoTabLn(": base(" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ")");
            _output.tabLevel--;
            _output.autoTabLn("{");
            _output.autoTabLn("");
            _output.autoTabLn("}");


            // Updated 7/15/2014 - by King Wilder - write custom code for SiteSetting - used by King Wilder
            if (table.Name == "SiteSetting")
            {
                _output.autoTabLn("public SiteSetting GetByKey(string key)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("return _dao.Get(s => s.Name == key).SingleOrDefault();");
                _output.tabLevel--;
                _output.autoTabLn("}");
            }


            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + "Service.cs");
            SaveOutput(CreateFullPath(_script.Settings.ServiceLayer.ServiceNamespace, StringFormatter.CleanUpClassName(table.Name) + "Service.cs"), SaveActions.DontOverwrite);
        }
        public void Delete(ITable table)
        {
            string tableName = table.Name;

            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// Delete " + StringFormatter.CleanUpClassName(tableName) + ".");
            _output.autoTabLn("/// </summary>");
            _output.autoTabLn("/// <param name=\"" + StringFormatter.CleanUpClassName(tableName) + "\"></param>");
            _output.autoTabLn("public void Delete(" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " model)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn(StringFormatter.CleanUpClassName(tableName) + " entity = new " + StringFormatter.CleanUpClassName(tableName) + "();");

            GenTable genTable = new GenTable(table, _context);
            string   args     = "";
            string   keys     = "";
            string   types    = "";

            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                // type + " " + key name
                args  += genTable.GetPrimaryKeyTypes[i] + " ";
                args  += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
                keys  += StringFormatter.PascalCasing(genTable.GetPrimaryKeyNames[i]) + ",";
                types += genTable.GetPrimaryKeyTypes[i] + ",";
            }
            // trim the trailing ", "
            args  = args.Substring(0, (args.Length - 2));
            keys  = keys.Substring(0, (keys.Length - 1));
            types = types.Substring(0, (types.Length - 1));

            _output.autoTabLn("if (entity.LoadByPrimaryKey(model." + keys + "))");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("entity.MarkAsDeleted();");
            _output.autoTabLn("entity.Save();");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
        }
Пример #10
0
 public void Render(string modelName)
 {
     _output.tabLevel--;
     foreach (string tableName in _script.Tables)
     {
         _output.tabLevel++;
         _output.autoTabLn("#region " + StringFormatter.CleanUpClassName(tableName) + " Mappers");
         _output.autoTabLn("");
         _output.autoTabLn("public static " + StringFormatter.CleanUpClassName(tableName) + modelName + " ToModel(this " + StringFormatter.CleanUpClassName(tableName) + " entity)");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("return AutoMapper.Mapper.Map<" + StringFormatter.CleanUpClassName(tableName) + ", " + StringFormatter.CleanUpClassName(tableName) + modelName + ">(entity);");
         _output.tabLevel--;
         _output.autoTabLn("}");
         _output.autoTabLn("");
         _output.autoTabLn("public static List<" + StringFormatter.CleanUpClassName(tableName) + modelName + "> ToModel(this List<" + StringFormatter.CleanUpClassName(tableName) + "> " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(tableName)) + "List)");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("var models = new List<" + StringFormatter.CleanUpClassName(tableName) + modelName + ">();");
         _output.autoTabLn("");
         _output.autoTabLn("if (" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(tableName)) + "List != null && " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(tableName)) + "List.Count > 0)");
         _output.tabLevel++;
         _output.autoTabLn(StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(tableName)) + "List.ForEach(b => models.Add(b.ToModel()));");
         _output.tabLevel--;
         _output.autoTabLn("");
         _output.autoTabLn("return models;");
         _output.tabLevel--;
         _output.autoTabLn("}");
         _output.autoTabLn("");
         _output.autoTabLn("public static " + StringFormatter.CleanUpClassName(tableName) + " FromModel(this " + StringFormatter.CleanUpClassName(tableName) + modelName + " model)");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("return AutoMapper.Mapper.Map<" + StringFormatter.CleanUpClassName(tableName) + modelName + ", " + StringFormatter.CleanUpClassName(tableName) + ">(model);");
         _output.tabLevel--;
         _output.autoTabLn("} ");
         _output.autoTabLn("#endregion");
         _output.autoTabLn("");
         _output.tabLevel--;
     }
     _output.tabLevel++;
 }
Пример #11
0
 public void RenderDaoInterface(ITable table)
 {
     _output.autoTabLn("using System;");
     _output.autoTabLn("using System.Linq;");
     _output.autoTabLn("using System.Collections.Generic;");
     _output.autoTabLn("");
     _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
     _output.autoTabLn("");
     _output.autoTabLn("namespace " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces");
     _output.autoTabLn("{");
     _output.tabLevel++;
     _output.autoTabLn("public interface I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " : ICRUD" + _script.Settings.DataOptions.ClassSuffix.Name + "<" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + ">");
     _output.autoTabLn("{");
     _output.tabLevel++;
     _output.autoTabLn("" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + " GetById(" + StringFormatter.CamelCasing(_context.Utility.RenderConcreteMethodParameters(table)) + ");");
     _output.autoTabLn("List<" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + "> GetAll(string sortExpression, int startRowIndex, int maximumRows);");
     _output.tabLevel--;
     _output.autoTabLn("}");
     _output.tabLevel--;
     _output.autoTabLn("}");
 }
Пример #12
0
        private void RenderServiceBaseClass(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            try
            {
                _output.autoTabLn("using System;");
                _output.autoTabLn("using System.Linq;");
                _output.autoTabLn("using System.Net;");
                _output.autoTabLn("using System.Net.Http;");
                _output.autoTabLn("using System.ServiceModel.Web;");
                _output.autoTabLn("using Microsoft.ApplicationServer.Http.Dispatcher;");
                _output.autoTabLn("");
                _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
                _output.autoTabLn("");
                _output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace);
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("");
                _output.autoTabLn("public partial class " + StringFormatter.CleanUpClassName(table.Name) + "Service");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("");
                _output.autoTabLn("#region " + StringFormatter.CleanUpClassName(table.Name) + " Members");
                _output.autoTabLn("");
                _output.autoTabLn("[WebGet(UriTemplate = \"{id}\")]");
                _output.autoTabLn("public HttpResponseMessage<BusinessObjects." + StringFormatter.CleanUpClassName(table.Name) + "> GetById(int id)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("var " + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + " = " + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".GetById(id);");
                _output.autoTabLn("if (" + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + " == null)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("var response = new HttpResponseMessage();");
                _output.autoTabLn("response.StatusCode = HttpStatusCode.NotFound;");
                _output.autoTabLn("response.Content = new StringContent(\"Contact not found\");");
                _output.autoTabLn("throw new HttpResponseException(response);");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("var " + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + "Response = new HttpResponseMessage<" + StringFormatter.CleanUpClassName(table.Name) + ">(" + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + ");");
                _output.autoTabLn("");
                _output.autoTabLn("//set it to expire in 5 minutes");
                _output.autoTabLn(StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + "Response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now.AddSeconds(30));");
                _output.autoTabLn("return " + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + "Response;");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("");
                _output.autoTabLn("[WebGet(UriTemplate=\"\")]");
                _output.autoTabLn("public IQueryable<BusinessObjects." + StringFormatter.CleanUpClassName(table.Name) + "> Get()");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("return " + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".GetAll().AsQueryable();");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("");
                _output.autoTabLn("[WebInvoke(UriTemplate = \"\", Method = \"POST\")]");
                _output.autoTabLn("public HttpResponseMessage<BusinessObjects." + StringFormatter.CleanUpClassName(table.Name) + "> Post(BusinessObjects." + StringFormatter.CleanUpClassName(table.Name) + " model)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("if (model == null)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("throw new HttpResponseException(HttpStatusCode.NotFound);");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("");
                _output.autoTabLn(StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".Insert(model);");
                _output.autoTabLn("");
                _output.autoTabLn("var response = new HttpResponseMessage<" + StringFormatter.CleanUpClassName(table.Name) + ">(model);");
                _output.autoTabLn("response.StatusCode = HttpStatusCode.Created;");
                _output.autoTabLn("return response;");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("");
                _output.autoTabLn("[WebInvoke(UriTemplate = \"{id}\", Method = \"PUT\")]");
                _output.autoTabLn("public BusinessObjects." + StringFormatter.CleanUpClassName(table.Name) + " Put(int id, BusinessObjects." + StringFormatter.CleanUpClassName(table.Name) + " model)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("if (id <= 0)");
                _output.tabLevel++;
                _output.autoTabLn("throw new HttpResponseException(\"id is missing\");");
                _output.tabLevel--;
                _output.autoTabLn("");
                _output.autoTabLn("if (model == null)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("var response = new HttpResponseMessage();");
                _output.autoTabLn("response.StatusCode = HttpStatusCode.NotFound;");
                _output.autoTabLn("response.Content = new StringContent(\"Contact not found\");");
                _output.autoTabLn("throw new HttpResponseException(response);");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("");
                _output.autoTabLn(StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".Update(model);");
                _output.autoTabLn("model = " + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".GetById(model.Id);");
                _output.autoTabLn("");
                _output.autoTabLn("return model;");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("");
                _output.autoTabLn("[WebInvoke(UriTemplate = \"{id}\", Method = \"DELETE\")]");
                _output.autoTabLn("public BusinessObjects." + StringFormatter.CleanUpClassName(table.Name) + " Delete(int id)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("if (id <= 0)");
                _output.tabLevel++;
                _output.autoTabLn("throw new HttpResponseException(\"id is missing\");");
                _output.tabLevel--;
                _output.autoTabLn("");
                _output.autoTabLn("var model = " + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".GetById(id);");
                _output.autoTabLn(StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".Delete(model);");
                _output.autoTabLn("");
                _output.autoTabLn("return model;");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("");
                _output.autoTabLn("#endregion");
                _output.autoTabLn("");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.tabLevel--;
                _output.autoTabLn("}");

                _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + "Service.cs");
                SaveOutput(CreateFullPath(_script.Settings.ServiceLayer.ServiceNamespace + "\\Generated", StringFormatter.CleanUpClassName(table.Name) + "Service.cs"), SaveActions.Overwrite);
            }
            catch (Exception ex)
            {
                throw new Exception("Error rendering ServiceBase class - " + ex.Message);
            }
        }
Пример #13
0
        private void RenderServiceBaseClass(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Collections.Generic;");
            _output.autoTabLn("using System.Linq;");
            _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
            _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces;");
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace + ".Generated");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public class " + StringFormatter.CleanUpClassName(table.Name) + "ServiceBase : IService<" + _context.Utility.BuildModelClassWithNameSpace(table.Name) + ">");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("#region Constructors");
            _output.autoTabLn("protected readonly I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " _" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ";");
            _output.autoTabLn("");
            _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + "ServiceBase(I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ")");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("this._" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + " = " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ";");
            _output.tabLevel--;
            _output.autoTabLn("} ");
            _output.autoTabLn("#endregion");
            _output.autoTabLn("");
            _output.autoTabLn("#region CRUD Methods");
            _output.autoTabLn("public IEnumerable<" + StringFormatter.CleanUpClassName(table.Name) + "> Get(System.Linq.Expressions.Expression<Func<" + StringFormatter.CleanUpClassName(table.Name) + ", bool>> filter = null, Func<IQueryable<" + StringFormatter.CleanUpClassName(table.Name) + ">, IOrderedQueryable<" + StringFormatter.CleanUpClassName(table.Name) + ">> orderBy = null, string includeProperties = \"\")");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("return _" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".Get(filter, orderBy, includeProperties);");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + " GetById(object id)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("return _" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".GetById(id);");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.autoTabLn("public void Insert(" + StringFormatter.CleanUpClassName(table.Name) + " entity)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("_" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".Insert(entity);");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.autoTabLn("public void Delete(object id)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn(StringFormatter.CleanUpClassName(table.Name) + " entity = _" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".GetById(id);");
            _output.autoTabLn("_" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".Delete(entity);");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.autoTabLn("public void Delete(" + StringFormatter.CleanUpClassName(table.Name) + " entityToDelete)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("_" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".Delete(entityToDelete);");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.autoTabLn("public void Update(" + StringFormatter.CleanUpClassName(table.Name) + " entityToUpdate)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("_" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".Update(entityToUpdate);");
            _output.tabLevel--;
            _output.autoTabLn("} ");
            _output.autoTabLn("#endregion");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("");
            _output.autoTabLn("}");

            _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + "ServiceBase.cs");
            SaveOutput(CreateFullPath(_script.Settings.ServiceLayer.ServiceNamespace + "\\Generated", StringFormatter.CleanUpClassName(table.Name) + "ServiceBase.cs"), SaveActions.Overwrite);
        }
Пример #14
0
        public void Insert(MyMeta.ITable table)
        {
            string tableName = table.Name;

            _output.tabLevel++;
            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// Insert new " + StringFormatter.CleanUpClassName(tableName) + ".");
            _output.autoTabLn("/// </summary>");
            _output.autoTabLn("/// <param name=\"" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(tableName)) + "\"></param>");
            _output.autoTabLn("/// <returns></returns>");
            _output.autoTabLn("public void Insert(" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " model)");
            _output.autoTabLn("{");

            _output.tabLevel++;
            _output.autoTabLn("var entity = " + StringFormatter.CleanUpClassName(tableName) + "Mapper.ToEntity(model);");
            _output.autoTabLn("");
            _output.autoTabLn("using (var context = DataContextFactory.CreateContext())");
            _output.autoTabLn("{");

            _output.tabLevel++;
            _output.autoTabLn("try");
            _output.autoTabLn("{");

            _output.tabLevel++;
            _output.autoTabLn("context." + StringFormatter.CleanUpClassName(StringFormatter.MakePlural(tableName)) + ".InsertOnSubmit(entity);");
            _output.autoTabLn("context.SubmitChanges();");

            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("catch (ChangeConflictException)");
            _output.autoTabLn("{");

            _output.tabLevel++;
            _output.autoTabLn("foreach (ObjectChangeConflict conflict in context.ChangeConflicts)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("conflict.Resolve(RefreshMode.KeepCurrentValues);");

            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("try");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("context.SubmitChanges();");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("catch (ChangeConflictException)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("throw new Exception(\"A concurrency error occurred!\");");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("catch (Exception)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("throw new Exception(\"There was an error inserting the record!\");");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _output.tabLevel--;
            _output.tabLevel--;
        }
        //public void Update(ITable table)
        //{
        //    string tableName = table.Name;

        //    _output.tabLevel++;
        //    _output.tabLevel++;
        //    _output.autoTabLn("/// <summary>");
        //    _output.autoTabLn("/// Update " + StringFormatter.CleanUpClassName(tableName) + ".  Map  fields to " + StringFormatter.CleanUpClassName(tableName) + " properties.");
        //    _output.autoTabLn("/// </summary>");
        //    _output.autoTabLn("/// <param name=\"" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(tableName)) + "\"></param>");
        //    _output.autoTabLn("/// <returns></returns>");
        //    _output.autoTabLn("public void Update(" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " model)");
        //    _output.autoTabLn("{");

        //    _output.tabLevel++;
        //    _output.autoTabLn("var entity = model.ToEntity();");
        //    _output.autoTabLn("");
        //    _output.autoTabLn("using (var context = DataObjectFactory.CreateContext())");
        //    _output.autoTabLn("{");
        //    _output.tabLevel++;

        //    _output.autoTabLn("context." + StringFormatter.CleanUpClassName(tableName, true) + ".Attach(entity);");
        //    _output.autoTabLn("context.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Modified);");
        //    _output.autoTabLn("context." + StringFormatter.CleanUpClassName(tableName, true) + ".ApplyCurrentValues(entity);");
        //    _output.autoTabLn("context.SaveChanges();");
        //    _output.tabLevel--;

        //    _output.autoTabLn("}");
        //    _output.tabLevel--;
        //    _output.autoTabLn("}");

        //    _output.tabLevel--;
        //    _output.tabLevel--;
        //}

        public void Delete(ITable table)
        {
            string tableName = table.Name;

            _output.tabLevel++;
            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// Delete " + StringFormatter.CleanUpClassName(tableName) + ".");
            _output.autoTabLn("/// </summary>");
            _output.autoTabLn("/// <param name=\"" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(tableName)) + "\"></param>");
            _output.autoTabLn("public void Delete(" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " model)");
            _output.autoTabLn("{");

            _output.tabLevel++;
            _output.autoTabLn("using (var context = DataObjectFactory.CreateContext())");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn(StringFormatter.CleanUpClassName(tableName) + " entity = null;");
            _output.autoTabLn("");
            _output.autoTabLn("entity = context." + StringFormatter.CleanUpClassName(tableName, true));
            _output.tabLevel++;

            GenTable genTable = new GenTable(table, _context);

            _output.tabLevel++;
            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                _output.autoTabLn(".Where(o => o." + genTable.GetPrimaryKeyNames[i] + " == model." + genTable.GetPrimaryKeyNames[i] + ")");
            }

            _output.autoTabLn(".SingleOrDefault();");
            _output.tabLevel--;
            _output.tabLevel--;
            _output.autoTabLn("");
            _output.autoTabLn("if (entity == null)");
            _output.tabLevel++;
            _output.autoTabLn("throw new NullReferenceException(\"The record doesn't exist or has been deleted by another user since you opened this record.\");");
            _output.tabLevel--;
            _output.autoTabLn("");
            _output.autoTabLn("context." + StringFormatter.CleanUpClassName(tableName, true) + ".DeleteObject(entity);");
            _output.autoTabLn("context.SaveChanges();");
            _output.tabLevel--;
            _output.autoTabLn("}");


            //_output.tabLevel++;
            //_output.autoTabLn("");
            //_output.autoTabLn("using (var context = DataObjectFactory.CreateContext())");
            //_output.autoTabLn("{");

            //_output.tabLevel++;
            //_output.autoTabLn("var entity = context." + StringFormatter.CleanUpClassName(tableName, true));

            //GenTable genTable = new GenTable(table, _context);
            //_output.tabLevel++;
            //for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            //{
            //    _output.autoTabLn(".Where(o => o." + genTable.GetPrimaryKeyNames[i] + " == model." + genTable.GetPrimaryKeyNames[i] + ")");
            //}

            //_output.autoTabLn(".SingleOrDefault();");
            //_output.tabLevel--;
            //_output.autoTabLn("context." + StringFormatter.CleanUpClassName(tableName, true) + ".DeleteObject(entity);");
            //_output.autoTabLn("context.SaveChanges();");

            //_output.tabLevel--;
            //_output.autoTabLn("}");



            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.tabLevel--;
        }
Пример #16
0
        private void RenderConcreteClass(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            try
            {
                _output.autoTabLn("using System;");
                _output.autoTabLn("using System.Linq;");
                _output.autoTabLn("using System.Net;");
                _output.autoTabLn("using System.Net.Http;");
                _output.autoTabLn("using System.ServiceModel;");
                _output.autoTabLn("using System.ServiceModel.Web;");
                _output.autoTabLn("using Microsoft.ApplicationServer.Http.Dispatcher;");
                _output.autoTabLn("using System.Text;");
                _output.autoTabLn("");
                _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
                _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces;");
                _output.autoTabLn("");
                _output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace);
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("[ServiceContract(Namespace = \"" + _script.Settings.ServiceLayer.DataContract + "\")]");
                _output.autoTabLn("public partial class " + StringFormatter.CleanUpClassName(table.Name) + "Service ");
                _output.autoTabLn("{");
                _output.autoTabLn("");
                _output.tabLevel++;
                _output.autoTabLn("#region ctors");
                _output.autoTabLn("private readonly I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " " + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ";");
                _output.autoTabLn("");
                _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + "Service(I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " " + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ")");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("this." + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + " = " + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ";");
                _output.tabLevel--;
                _output.autoTabLn("} ");
                _output.autoTabLn("#endregion");
                _output.autoTabLn("");
                _output.autoTabLn("");
                _output.autoTabLn("//[WebGet(UriTemplate = \"/title/{title}\")]");
                _output.autoTabLn("//public HttpResponseMessage<" + StringFormatter.CleanUpClassName(table.Name) + "> GetByTitle(string title)");
                _output.autoTabLn("//{");
                _output.autoTabLn("//	if (string.IsNullOrEmpty(title))");
                _output.autoTabLn("//		throw new HttpResponseException(HttpStatusCode.NotFound);");
                _output.tabLevel++;
                _output.autoTabLn("");
                _output.tabLevel--;
                _output.autoTabLn("//	var "+ StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + " = " + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".GetAll().Where(b => b.Title.ToLower() == title.ToLower()).SingleOrDefault();");
                _output.autoTabLn("//	if ("+ StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + " == null)");
                _output.autoTabLn("//	{");
                _output.autoTabLn("//		var response = new HttpResponseMessage();");
                _output.autoTabLn("//		response.StatusCode = HttpStatusCode.NotFound;");
                _output.autoTabLn("//		response.Content = new StringContent(\""+ StringFormatter.CleanUpClassName(table.Name) + " not found\");");
                _output.autoTabLn("//		throw new HttpResponseException(response);");
                _output.autoTabLn("//	}");
                _output.autoTabLn("//	var "+ StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + "Response = new HttpResponseMessage<" + StringFormatter.CleanUpClassName(table.Name) + ">(" + StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + ");");
                _output.tabLevel++;
                _output.autoTabLn("");
                _output.tabLevel--;
                _output.autoTabLn("//	//set it to expire in 5 minutes");
                _output.autoTabLn("//	"+ StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + "Response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now.AddSeconds(30));");
                _output.autoTabLn("//	return "+ StringFormatter.CleanUpClassName(StringFormatter.CamelCasing(table.Name)) + "Response;");
                _output.autoTabLn("//}");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.tabLevel--;
                _output.autoTabLn("}");

                _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + "Service.cs");
                SaveOutput(CreateFullPath(_script.Settings.ServiceLayer.ServiceNamespace + "\\api\\v1.0", StringFormatter.CleanUpClassName(table.Name) + "Service.cs"), SaveActions.DontOverwrite);
            }
            catch (Exception ex)
            {
                throw new Exception("Error rendering ServiceLayer Concrete class - " + ex.Message);
            }
        }
        public void Insert(ITable table)
        {
            string tableName = table.Name;

            _output.tabLevel++;
            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// Insert new " + StringFormatter.CleanUpClassName(tableName) + ".");
            _output.autoTabLn("/// </summary>");
            _output.autoTabLn("/// <param name=\"" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(tableName)) + "\"></param>");
            _output.autoTabLn("/// <returns></returns>");
            _output.autoTabLn("public void Insert(" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " model)");
            _output.autoTabLn("{");

            _output.tabLevel++;
            _output.autoTabLn("var entity = model.ToEntity();");
            _output.autoTabLn("");
            _output.autoTabLn("using (var context = DataObjectFactory.CreateContext())");
            _output.autoTabLn("{");

            _output.tabLevel++;
            _output.autoTabLn("context." + StringFormatter.CleanUpClassName(tableName, true) + ".AddObject(entity);");
            _output.autoTabLn("context.SaveChanges();");

            // Updated 7/21/2011 by King Wilder
            // New addition to return the new entity ID

            /****** Begin new code ******/
            GenTable genTable = new GenTable(table, _context);
            string   args     = "";
            string   keys     = "";

            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                // type + " " + key name
                args += genTable.GetPrimaryKeyTypes[i] + " ";
                args += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
                keys += StringFormatter.PascalCasing(genTable.GetPrimaryKeyNames[i]) + ",";
            }
            // trim the trailing ", "
            args = args.Substring(0, (args.Length - 2));
            keys = keys.Substring(0, (keys.Length - 1));

            string[] keysSplit = keys.Split(',');
            foreach (string key in keysSplit)
            {
                _output.autoTabLn("model." + key.Trim() + " = entity." + key.Trim() + ";");
            }
            /****** End new code ******/



            _output.tabLevel--;

            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _output.tabLevel--;
            _output.tabLevel--;
        }
Пример #18
0
        private void RenderServiceBaseClass(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            try
            {
                _output.autoTabLn("using System.Collections.Generic;");
                _output.autoTabLn("using System.Linq;");
                _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
                _output.autoTabLn("using " + _script.Settings.ServiceLayer.ServiceNamespace + ".Interfaces;");
                _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ";");
                _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces;");
                _output.autoTabLn("");
                _output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace);
                _output.autoTabLn("{");
                _output.autoTabLn("    public class " + StringFormatter.CleanUpClassName(table.Name) + "ServiceBase : ICRUDService<" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + ">");
                _output.autoTabLn("    {");
                _output.tabLevel++;
                _output.autoTabLn("#region Dependency Injection");
                _output.autoTabLn("");
                _output.autoTabLn("protected I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ";");
                _output.tabLevel--;
                _output.autoTabLn("");
                _output.tabLevel++;
                _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + "ServiceBase(I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " " + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ")");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("this." + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + " = " + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ";");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("");
                _output.autoTabLn("#endregion");
                _output.tabLevel--;
                _output.autoTabLn("");
                _output.tabLevel++;
                _output.autoTabLn("public List<" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + "> GetAll()");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("return " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".GetAll().ToList();");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.tabLevel--;
                _output.autoTabLn("");
                _output.tabLevel++;
                _output.autoTabLn("public void Insert(" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + " model)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("EntLibValidation.Validator<" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + ">.Validate(model);");
                _output.autoTabLn("" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".Insert(model);");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.tabLevel--;
                _output.autoTabLn("");
                _output.tabLevel++;
                _output.autoTabLn("public void Update(" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + " model)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("EntLibValidation.Validator<" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + ">.Validate(model);");
                _output.autoTabLn("" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".Update(model);");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.tabLevel--;
                _output.autoTabLn("");
                _output.tabLevel++;
                _output.autoTabLn("public void Delete(" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + " model)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("EntLibValidation.Validator<" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + ">.Validate(model);");
                _output.autoTabLn("" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".Delete(model);");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.tabLevel--;
                _output.autoTabLn("    }");
                _output.autoTabLn("}");

                _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + "ServiceBase.cs");
                SaveOutput(CreateFullPath(_script.Settings.ServiceLayer.ServiceNamespace + "\\Generated", StringFormatter.CleanUpClassName(table.Name) + "ServiceBase.cs"), SaveActions.Overwrite);
            }
            catch (Exception ex)
            {
                throw new Exception("Error rendering ServiceBase class - " + ex.Message);
            }
        }
Пример #19
0
        private void RenderConcreteClass(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            try
            {
                GenTable genTable   = new GenTable(table, _context);
                string   sortColumn = genTable.GetFirstStringColumnName();

                _output.autoTabLn("using System;");
                _output.autoTabLn("using System.Collections.Generic;");
                _output.autoTabLn("using System.Linq;");
                _output.autoTabLn("using System.Text;");
                _output.autoTabLn("");
                _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
                _output.autoTabLn("using " + _script.Settings.ServiceLayer.ServiceNamespace + ".Interfaces;");
                _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ";");
                _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces;");
                _output.autoTabLn("");
                _output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace);
                _output.autoTabLn("{");
                _output.autoTabLn("    public class " + StringFormatter.CleanUpClassName(table.Name) + "Service : " + StringFormatter.CleanUpClassName(table.Name) + "ServiceBase, I" + StringFormatter.CleanUpClassName(table.Name) + "Service");
                _output.autoTabLn("    {");
                _output.autoTabLn("");
                _output.tabLevel++;
                _output.autoTabLn("#region Dependency Injection");
                _output.tabLevel++;
                _output.autoTabLn("");
                _output.tabLevel--;
                _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + "Service(I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " " + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + "):base(" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ")");
                _output.autoTabLn("{");
                _output.autoTabLn("}");
                _output.autoTabLn("");
                _output.autoTabLn("#endregion");
                _output.tabLevel--;
                _output.autoTabLn("");
                _output.tabLevel++;
                _output.autoTabLn("#region I" + StringFormatter.CleanUpClassName(table.Name) + "Service Members");
                _output.tabLevel--;
                _output.autoTabLn("");
                _output.tabLevel++;
                _output.autoTabLn("public List<" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + "> GetAll(string sortExpression, int startRowIndex, int maximumRows)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("if (string.IsNullOrEmpty(sortExpression))");
                _output.tabLevel++;
                _output.autoTabLn("sortExpression = \"" + sortColumn + "\";");
                _output.tabLevel--;
                _output.tabLevel--;
                _output.autoTabLn("");
                _output.tabLevel++;
                _output.autoTabLn("return " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".GetAll(sortExpression, startRowIndex, maximumRows);");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.tabLevel--;
                _output.autoTabLn("");
                _output.tabLevel++;
                _output.autoTabLn("public int GetCount()");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("return " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".GetAll().Count;");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("");
                _output.autoTabLn("public " + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + " GetById(int Id)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("return " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ".GetById(Id);");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.tabLevel--;
                _output.autoTabLn("");
                _output.tabLevel++;
                _output.autoTabLn("#endregion");
                _output.tabLevel--;
                _output.autoTabLn("    }");
                _output.autoTabLn("}");

                _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + "Service.cs");
                SaveOutput(CreateFullPath(_script.Settings.ServiceLayer.ServiceNamespace, StringFormatter.CleanUpClassName(table.Name) + "Service.cs"), SaveActions.DontOverwrite);
            }
            catch (Exception ex)
            {
                throw new Exception("Error rendering ServiceLayer Concrete class - " + ex.Message);
            }
        }
Пример #20
0
        private void RenderApiControllerClass(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Collections.Generic;");
            _output.autoTabLn("using System.Linq;");
            _output.autoTabLn("using System.Linq.Expressions;");
            _output.autoTabLn("");
            _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
            _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ";");
            _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces;");
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace + ".Controllers");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// This is the WebApi controller for the " + StringFormatter.CleanUpClassName(table.Name) + " entity.");
            _output.autoTabLn("/// </summary>");
            _output.autoTabLn("public class " + StringFormatter.CleanUpClassName(table.Name) + "Controller : BaseController<" + StringFormatter.CleanUpClassName(table.Name) + ">");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("#region ctors");
            _output.autoTabLn("private readonly I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " _" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ";");
            _output.autoTabLn("private readonly IUnitOfWork _unitOfWork;");
            _output.autoTabLn("");
            _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + "Controller(I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ", IUnitOfWork unitOfWork) : base(" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ", unitOfWork)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("this._unitOfWork = unitOfWork;");
            _output.autoTabLn("this._" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + " = " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ";");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.autoTabLn("#endregion");
            _output.autoTabLn("");
            _output.autoTabLn("#region Custom Actions");
            _output.autoTabLn("");
            _output.autoTabLn("///// <summary>");
            _output.autoTabLn("///// This is a custom action that returns Product by category.");
            _output.autoTabLn("///// Check how the route is created in the RouteConfig.cs file in the App_Start folder.");
            _output.autoTabLn("///// </summary>");
            _output.autoTabLn("///// <param name=\"category\">Category Name</param>");
            _output.autoTabLn("///// <returns></returns>");
            _output.autoTabLn("//public List<Product> GetProductsByCategory(string category)");
            _output.autoTabLn("//{");
            _output.autoTabLn("//	Expression<Func<Product, bool>> exp = null;");
            _output.autoTabLn("//	if (!string.IsNullOrEmpty(category))");
            _output.autoTabLn("//		exp = c => c.Category.CategoryName.ToLower() == category.ToLower();");
            _output.autoTabLn("");
            _output.autoTabLn("//	return _productRepository.Get(exp).ToList();");
            _output.autoTabLn("//}");
            _output.autoTabLn("");
            _output.autoTabLn("///// <summary>");
            _output.autoTabLn("///// Get a Product by name.  Check the RouteConfig.cs file for routing.");
            _output.autoTabLn("///// </summary>");
            _output.autoTabLn("///// <param name=\"name\">Product Name</param>");
            _output.autoTabLn("///// <returns></returns>");
            _output.autoTabLn("//public Product GetProductByName(string name)");
            _output.autoTabLn("//{");
            _output.autoTabLn("");
            _output.autoTabLn("//	Product product = _productRepository.Get(p => p.Name.ToLower() == name.ToLower()).SingleOrDefault();");
            _output.autoTabLn("//	if (product == null)");
            _output.autoTabLn("//		throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));");
            _output.autoTabLn("");
            _output.autoTabLn("//	return product;");
            _output.autoTabLn("//}");
            _output.autoTabLn("");
            _output.autoTabLn("///// <summary>");
            _output.autoTabLn("///// Calculate the tax for a product. (Example PUT method.)");
            _output.autoTabLn("///// </summary>");
            _output.autoTabLn("///// <param name=\"name\">Product model</param>");
            _output.autoTabLn("///// <returns></returns>");
            _output.autoTabLn("//[HttpPut]");
            _output.autoTabLn("//public Product CalculateTax(Product model)");
            _output.autoTabLn("//{");
            _output.autoTabLn("//	if (ModelState.IsValid)");
            _output.autoTabLn("//	{");
            _output.autoTabLn("//		try");
            _output.autoTabLn("//		{");
            _output.autoTabLn("//			var tax = model.Amount * _taxRate;");
            _output.autoTabLn("//			_groupDao.UpdateTax(tax);");
            _output.autoTabLn("//			_unitOfWork.ActionEntities.Commit();");
            _output.autoTabLn("//			");
            _output.autoTabLn("//		}");
            _output.autoTabLn("//		catch (Exception)");
            _output.autoTabLn("//		{");
            _output.autoTabLn("//			return Request.CreateResponse(HttpStatusCode.NotFound);");
            _output.autoTabLn("//		}");
            _output.autoTabLn("//		return Request.CreateResponse(HttpStatusCode.OK, model);");
            _output.autoTabLn("//	}");
            _output.autoTabLn("//	else");
            _output.autoTabLn("//	{");
            _output.autoTabLn("//		return Request.CreateResponse(HttpStatusCode.BadRequest);");
            _output.autoTabLn("//	}");
            _output.autoTabLn("//}");
            _output.autoTabLn("");
            _output.autoTabLn("#endregion");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + "Controller.cs");
            SaveOutput(CreateFullPath(_script.Settings.ServiceLayer.ServiceNamespace + "\\Controllers", StringFormatter.CleanUpClassName(table.Name) + "Controller.cs"), SaveActions.DontOverwrite);
        }
        private void RenderDataObjectsBaseClass()
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Data.Entity;");
            _output.autoTabLn("using System.Linq;");
            _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.DataOptions.DataObjectsNamespace + ".Generated");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public class DataObjectsBase : DbContext");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("#region Private Variables");
            _output.autoTabLn("");

            foreach (string tableName in _script.Tables)
            {
                _output.autoTabLn("private IDbSet<" + StringFormatter.CleanUpClassName(tableName) + "> _" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(tableName, true)) + ";");
            }


            _output.autoTabLn("");
            _output.autoTabLn("#endregion");
            _output.autoTabLn("");
            _output.autoTabLn("#region ctors");
            _output.autoTabLn("");
            _output.autoTabLn("public DataObjectsBase(string connectionString)");
            _output.tabLevel++;
            _output.autoTabLn(": base(connectionString)");
            _output.tabLevel--;
            _output.autoTabLn("{");
            _output.autoTabLn("");
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.autoTabLn("#endregion");
            _output.autoTabLn("");
            _output.autoTabLn("#region Public Properties");

            foreach (string tableName in _script.Tables)
            {
                _output.autoTabLn("public IDbSet<" + StringFormatter.CleanUpClassName(tableName) + "> " + StringFormatter.CleanUpClassName(tableName, true) + "");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("get");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("return _" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(tableName, true)) + " ?? (_" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(tableName, true)) + " = Set<" + StringFormatter.CleanUpClassName(tableName) + ">());");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("");
            }


            _output.autoTabLn("#endregion");
            _output.autoTabLn("");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _context.FileList.Add("    DataObjectsBase.cs");
            SaveOutput(CreateFullPath(_script.Settings.DataOptions.DataObjectsNamespace + "\\Generated", "DataObjectsBase.cs"), SaveActions.Overwrite);
        }