The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

My Generation

Last post 05-23-2008, 11:26 AM by TrevorW. 6 replies.
Sort Posts: Previous Next
  •  05-22-2008, 4:38 PM 9408

    My Generation

    Sorry to write this here, but I am having no luck with My Generation forum. My user/forum account was inactivated and there is no option to 'reactivate' the account; I have no idea why it was inactivated. I tried activating a new account and I kept getting error messages that an email could not be sent...so...

    I am wondering what the best (easiest) technique is for copying a template? Currently, I manually locate the template I want to copy, copy it, rename it, move it to the desired template directory and then manually generate a new GUID. For the life of me I cannot figure out why there isn't a simple context menu option for copy and pasting templates within My Generation... is there? Shouldn't there be?

     TIA

  •  05-22-2008, 5:14 PM 9409 in reply to 9408

    Re: My Generation

    We never created such a mechanism actually, it's a good idea however. MyGeneration is open source and not too many folks have really been interested in it. Now that I do ES I unfortunately don't have the time. As for the forums, it's a sad story. We use PHPBB and since its widely used bots are used to post porn on them all the time, basically, its impossible to register on the MyGeneration forums as I got tired of finding porn pictures in posts in the morning and MyGeneration has my name all over and I just cannot have that.

    So, I guess for now you're doing it the way you have to, wish there was a better way.  


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  05-22-2008, 5:55 PM 9411 in reply to 9409

    Re: My Generation

    First, thank you! I can live with it the way it is.

    I do have another question about MyGeneration and specifically with the ES templates.

    I need to create a single class from database schema with nested classes and I'm not sure how to setup the templates to keep looping and loop thru all the tables and save the whole thing as one file.

     As you know, I am working on a Query Builder utility/ GUI and I discovered that its also useful within VS as well as the GUI.

    I want to build classes similar to this:

    Code:
        public static class QueryDataConstants {
    
    
            public static class Tables {
    
                /// <summary>
                /// The Employees table.
                /// </summary>
                public static class Employees {
                    public const string Name = "Employees";
                    public const string Alias = "e";
    
    
                    /// <summary>
                    /// The Employees table primary key fields.
                    /// </summary>
                    public static class PrimaryKeyFields {
                        public const string EmployeeID = "EmployeeID";
                    }
    
                    public static class Fields {
    
                        public static class EmployeeID {
                            public const string Name = "EmployeeID";
                            public const string DatabaseType = "int";
                            public const string SystemType = "System.Int32";
                        }
    
                        public static class FirstName {
                            public const string Name = "FirstName";
                            public const string DatabaseType = "nvarchar";
                            public const string SystemType = "System.String";
                        }
    
                        public static class LastName {
                            public const string Name = "LastName";
                            public const string DatabaseType = "nvarchar";
                            public const string SystemType = "System.String";
                        }
    
                        public static class Title {
                            public const string Name = "Title";
                            public const string DatabaseType = "nvarchar";
                            public const string SystemType = "System.String";
                        }
    
                        public static class TitleOfCourtesy {
                            public const string Name = "TitleOfCourtesy";
                            public const string DatabaseType = "nvarchar";
                            public const string SystemType = "System.String";
                        }
    
                        public static class BirthDate {
                            public const string Name = "BirthDate";
                            public const string DatabaseType = "datetime";
                            public const string SystemType = "System.DateTime";
                        }
    
                        public static class HireDate {
                            public const string Name = "HireDate";
                            public const string DatabaseType = "datetime";
                            public const string SystemType = "System.DateTime";
                        }
                    }
                }
    
                /// <summary>
                /// The EmployeeTerritories table.
                /// </summary>
                public static class EmployeeTerritories {
                    public const string Name = "EmployeeTerritories";
                    public const string Alias = "et";
                }
    
                /// <summary>
                /// The Territories table.
                /// </summary>
                public static class Territories {
                    public const string Name = "Territories";
                    public const string Alias = "t";
                }
            }
        }

     

    This allows for the easiest references to database schema I can think of using intellisense.

    Here i a sample getting to the 'EmployeeID' of the 'Employees' table:

    Code:
    string employeeID = QueryDataConstants.Tables.Employees.Fields.EmployeeID;

    Here is a screenshot of intellisense:

     

    Query Intellisense

    Anyways, I believe this section from an ES My Generation template needs to be modified (I copied the template into my own and modified all the rest just fine, I just need to save the whole thing as one file rather than one for each table):

    Code:
    	// Save the output file for this Table/View
    	private void SaveFile()
    	{
    	
        	string filename = input["txtPath"].ToString();
    		if (!filename.EndsWith("\\") ) 
    			filename += "\\";
    		
    		filename += "I" + esPlugIn.Entity(source) + ".cs";
    		
    		// This overwrites files with the same name
    		// without prompting. If you do not want to
    		// overwrite files with the same name, then
    		// use the following:
    		// output.save(filename, "d");
    		output.save(filename, false);
    		
    		// This accumulates all output for all tables/views
    		// for display on the Output tab, above. Then, it clears
    		// the output, so each file saved only has the
    		// generated code for the one table/view.
    		outputBuffer += output.text;
    		output.clear();
    		
    		context.Log.Write("Created " + filename);		
    	}

     

    If you could help me modify that to save all the tables in one file, I would be very appreciative.

     

  •  05-22-2008, 6:41 PM 9412 in reply to 9408

    Re: My Generation

    These are the steps I use to copy a MyGeneration 1.2.0.7 template to be used as the starting point for a new template. It is all done within MyGeneration. It's not as simple as having a "Copy" button, but it's pretty painless.

    • Open the template you want to copy.
    • Open the Template Properties panel. (Click on the collapsible splitter on the left of the window, or click on the Properties icon, to the right of the "As" diskette icon at the top of the window.)
    • Click the New Guid button. Each template must have a Unique Id.
    • Change the Title.
    • Change the Namespace. Do not use the EntitySpaces namespace.
    • Click File -> Save As (or the "As" diskette icon at the top of the window.)
    • Change the "File name".
    • Change the "Save in" location.
        (The MyGeneration Template Browser uses the namespace to organize
         things. The Save location of the template can be anywhere you
         want beneath the MyGeneration\Templates folder, but you will
         find maintenance much easier if you create a Windows folder
         structure that matches your namespace structure.)
    • Click "Save".
    • You are now ready to replace the Template/Interface Code with your own.

    David Neal Parsons
    www.entityspaces.net
  •  05-22-2008, 7:10 PM 9413 in reply to 9411

    Re: My Generation

    Re: SaveFile()

    I do not think the problem is with that method, but where you are calling it from within your code. If the SaveFile() call is inside your table loop, it will write separate files for each table. Just move that line down below the end of the table loop. I think the only thing you need to change in that method is the filename. As is, it would use the table name of the last table in the loop.


    David Neal Parsons
    www.entityspaces.net
  •  05-23-2008, 4:24 AM 9417 in reply to 9411

    Re: My Generation

    Hi Trevor

    As David's said, if you move the call to SaveFile() so that it's outside of your table/view loop that would do the trick - in fact I have an example MyGen template that does this for creating an EntityFactory (of sorts) whereby it creates a series of "Select....Case..." statements to return a newly created entity of a given type (I wanted to avoid reflection at that point) - while the code generated is simple enough I'll happily share it if you want/need so you can see how the loop and final call to SaveFile() is called - let me know and if you want I'll email it/post it when I get home tonight (it's on my dev machine there).

    Cheers

    Martin

  •  05-23-2008, 11:26 AM 9424 in reply to 9417

    Re: My Generation

    Thank everyone!

    DOH! I was suffering from "Up too late with eyes turning red syndrome!"

    It was right in front of me and I just "missed it".

    Thanks!

     

View as RSS news feed in XML