Monday, June 18, 2007

MyGeneration is now an open source project under the BSD license on SourceForge.net, you can find the project HERE. This is not the end, but a new beginning for MyGeneration. You can easily sync up and compile MyGeneration right out of the box. You will most likely just need to remove the MyMetaVistaDB3xPlugin project unless you happen to have VistaDB on your system.

I created a folder called C:\MyGen and mapped my TortoiseSVN to https://mygeneration.svn.sourceforge.net/svnroot/mygeneration and did a full sync. Using this example you will find the overall solution here C:\MyGen\trunk\mygeneration\Zeus.sln.

Again, you can find the MyGeneration project on SourceForget.net HERE

 

posted on Monday, June 18, 2007 10:40:08 AM (Eastern Standard Time, UTC-05:00)  #   
 Thursday, June 14, 2007

Epoxy is a REST/POX webservice API that extends the EntitySpaces Architecture. If you are unfamiliar with what REST/POX is I would recommend checking out the excellent series over at Softies On Rails. This addition is meant to empower the creation of massively public http API's for any application that you develop with the EntitySpaces Architecture. Why would you want to expose your EntitySpaces objects via REST/POX and not just provide the defacto SOAP service API? Well, lets face it not everyone is living in the .NET world. Don't you want all your cool ruby coding friends to be able to consume your services easily? Of course you do, not to mention the 100's of other geeks that will write clients if only you allow them to do it in the language of their choice without jumping through a lot of hoops. For a more authoritative answer on when to use REST/POX instead of or in conjunction with SOAP, check out what Don Box has to say about it.

So now that we all agree that this is indeed something very useful, lets get down to implementation. We chose to use the new WCF REST/POX facilities to create our services. Below is a sample of our Service Contract

[ServiceContract]
public interface IUniversalContract
{
    [OperationContract(Action = "*", ReplyAction = "*")]
    Message ProcessMessage(Message input);
}

As you can see our interface consists of one Operation Contract which simply takes a Message as an input. The implementation of the interface is where the rubber hits the road. Below is a sample implementation of the above defined interface using the Employees class generated from the Northwind sample database.

public Message ProcessMessage(Message request)
{
    Message response = null;

    //The HTTP Method (e.g. GET) from the incoming HTTP request
    //can be found on the HttpRequestMessageProperty. The MessageProperty
    //is added by the HTTP Transport when the message is received.
    HttpRequestMessageProperty requestProperties =
        (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name];

    //Here we dispatch to different internal implementation methods
    //based on the incoming HTTP verb.
    if (requestProperties != null)
    {
        if (String.Equals("GET", requestProperties.Method,
            StringComparison.OrdinalIgnoreCase))
        {
            response = GetEmployee(request);
        }
        else if (String.Equals("PUT", requestProperties.Method,
            StringComparison.OrdinalIgnoreCase))
        {
            response = UpdateEmployee(request);
        }
        else if (String.Equals("POST", requestProperties.Method,
            StringComparison.OrdinalIgnoreCase))
        {
            response = AddEmployee(request);
        }
        else if (String.Equals("DELETE", requestProperties.Method,
            StringComparison.OrdinalIgnoreCase))
        {
            response = DeleteEmployee(request);
        }
        else
        {
            //This service doesn't implement handlers for other HTTP verbs (such as HEAD), so we
            //construct a response message and use the HttpResponseMessageProperty to
            //set the HTTP status code to 405 (Method Not Allowed) which indicates the client
            //used an HTTP verb not supported by the server.
            response = Message.CreateMessage(MessageVersion.None, String.Empty, String.Empty);

            HttpResponseMessageProperty responseProperty = new HttpResponseMessageProperty();
            responseProperty.StatusCode = HttpStatusCode.MethodNotAllowed;

            response.Properties.Add( HttpResponseMessageProperty.Name, responseProperty );
        }
    }
    else
    {
        throw new InvalidOperationException( "This service requires the HTTP transport" );
    }

    return response;
}

As you can see the above maps various http verbs to our CRUD methods for our objects. Using the new EntitySpaces WCF support the WCF serialization worked like a charm.

Endpoints are very important in a REST'ful API, so its worth covering briefly how the WCF implementation handles this. For the context of this post my virtual directory locally is ServiceHost. The actual service file will be called employee.svc in this sample. This relates directly to the address you will use to interact with the API over HTTP.

**Note if you want this to work you must have WCF installed, be using EntitySpaces Developer 0614 or higher and configure IIS for WCF REST/POX operations.

In our sample to get a list of all employees you would hit

http://localhost/servicehost/employees.svc/employees/

this would produce the following XML

<ArrayOfanyURI xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays"
    xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <anyURI>http://scattorshot/servicehost/employees.svc/employees/1</anyURI>
    <anyURI>http://scattorshot/servicehost/employees.svc/employees/2</anyURI>
    <anyURI>http://scattorshot/servicehost/employees.svc/employees/3</anyURI>
</ArrayOfanyURI>

As you can see it provides you with a list or URI's for each employee in the list. You can also perform an HTTP POST to this address to add a new employee. You may retrieve a single employee with an EmployeeID of 1 by performing an HTTP GET to the below address

http://localhost/servicehost/employees.svc/employees/1

this would produce the following XML

<Employees>
    <EmployeeID>1</EmployeeID>
    <LastName>Davolio</LastName>
    <FirstName>Nancy</FirstName>
    <Title>Sales Representative</Title>
    <TitleOfCourtesy>Ms.</TitleOfCourtesy>
    <BirthDate>1948-12-08T00:00:00</BirthDate>
    <HireDate>1992-05-01T00:00:00</HireDate>
    <Address>507 - 20th Ave. E. Apt. 2A</Address>
    <City>Seattle</City>
    <Region>WA</Region>
    <PostalCode>98122</PostalCode>
    <Country>USA</Country>
    <HomePhone>(206) 555-9857</HomePhone>
    <Extension>5467</Extension>
    <Photo>
        FRwvAAIAAn....the long base64 encoded string
    </Photo>
    <Notes>
        Education includes a BA in psychology from Colorado State University in 1970. 
        She also completed "The Art of the Cold Call."  Nancy is a member of Toastmasters International.
    </Notes>
    <ReportsTo>2</ReportsTo>
    <PhotoPath>http://accweb/emmployees/davolio.bmp</PhotoPath>
    <esRowState>Unchanged</esRowState>
</Employees>

After performing the HTTP GET and retrieving the desired employee resource you could modify it, and then perform an HTTP PUT to the same endpoint to update the employee. In order to delete an employee you would perform an HTTP DELETE to the above address to delete the resource. This is how your endpoints relate to your HTTP verbs, and is at the very heart of the REST style architecture.

So now you not only have the option to expose your EntitySpaces objects via SOAP services but REST/POX as well. We will be providing the full source code for the sample services as well as a small Windows Form client to consume the service. Choice is always a good thing, and this is certainly no exception.

EntitySpaces

From mobile devices to large scale enterprise solutions in need of serious transaction support, EntitySpaces can meet your needs. Whether you’re writing an ASP.NET application with medium trust requirements, or a Windows.Forms application, the EntitySpaces architecture is there for you. EntitySpaces is provider independent, which means that you can run the same binary code against any of the supported databases.EntitySpaces is available in both C# and VB.NET. EntitySpaces uses no reflection, no XML files, and sports a tiny foot print of less than 200k. Pound for pound, EntitySpaces is one tough, dependable .NET architecture.

The EntitySpaces Team
--

EntitySpaces LLC
Persistence Layer and Business Objects for Microsoft .NET
http://www.entityspaces.net

EntitySpaces.RestPox.zip (93.44 KB)
posted on Thursday, June 14, 2007 8:29:15 PM (Eastern Standard Time, UTC-05:00)  #   
EntitySpaces.RestPox.zip (93.44 KB)
 Saturday, June 09, 2007

The Windows Communication Foundation (WCF) has some interesting challenges when it comes to serialization. The model chosen by Microsoft does not work out-of-the-box and doesn't obey attributes such as [XmlIgnore] and alike. So, while you're classes might serialize perfectly in SOAP scenarios you'll be scratching your head when it comes to WCF serialization (in most cases). Of course, EntitySpaces supports binary serialization and you can certainly very easily use our binary serialization for WCF remoting when you are in control of both the client and server.

EntitySpaces is sporting a new tab on the "Generated Master" template in our upcoming ES2007 maintenance release. This release will most likely arrive on June 23rd, however, an internal beta will be provided for those doing WCF now, no public beta will be posted. If you are interested in working with our WCF support please email us support@entityspaces.net

So, if you are doing WCF programming this new release is definitely for you. 

 


Using the Employees table from Microsoft's Northwind database let's take a look at how to use the EntitySpaces WCF proxy stub classes. You can use the same proxy stub class on both the server and the client side. The proxy stub classes will automatically be placed in your generated "single file" during the code generation process. Two class will be created:

  1. EmployeesProxyStub
  2. EmployeesCollectionProxyStub

These are both lightweight intelligent wrappers that cause your EntitySpaces objects to be serialized correctly when used in WCF communications scenarios. This post is only going to cover the EmployeesProxyStub class, the EmployeesCollectionProxyStub will be covered in a follow up post. However, the collection proxy stub code has already been written and tested.

The EmployeesProxyStub

This is the wrapper for your single entity classes. You can use the proxy stub class to return data from the server to the client simply by executing this code.

 

public EmployeesProxyStub SomeMethod(int id)
{
    Employees employee = new Employees();
    employee.LoadByPrimaryKey(id);
    return new EmployeesProxyStub(employee);
}

 

The XML will look something like this. Notice that only the non-null columns are returned. This is because we checked the "EmitDefaultValue=False" checkbox on the template, otherwise there would have been place holder elements in the XML for those columns that were null.

 

<Employees xmlns="http://tempuri.org/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <EmployeeID>257</EmployeeID>
    <LastName>Goo</LastName>
    <FirstName>foo</FirstName>
    <esRowState>Unchanged</esRowState>
</Employees>

 

This is an example of the generated proxy stub class. 

 

[DataContract(Namespace = "http://tempuri.org/", Name = "Employees")]
[Serializable]
public class EmployeesProxyStub
{
    public EmployeesProxyStub(Employees obj)
    {
        this.entity = obj;
    }

    [DataMember(Order = 1, EmitDefaultValue = false)]  // EmitDefaultValue -> see checkbox above
    public System.Int32? EmployeeID
    {
        get
        {
            if (this.Entity.es.IsDeleted)
                return (System.Int32?)this.Entity.
                    GetOriginalColumnValue(EmployeesMetadata.PropertyNames.EmployeeID);
            else
                return this.Entity.EmployeeID;
        }
       set { this.Entity.EmployeeID = value; }
    }

    [DataMember(Order = 2, EmitDefaultValue = false)]  // EmitDefaultValue -> see checkbox above
    public System.String FirstName
    {
        get
        {
            if (this.Entity.es.IsDeleted)
                return null;
            else
                return this.Entity.FirstName;
        }
        set { this.Entity.FirstName = value; }
    }

    // and more properties are in here ....

    [DataMember(Order=19)]
    public string esRowState  // Present only if "Include Added/Modified/Deleted" is clicked
    {
        get
        {
            return this.Entity.es.RowState.ToString();
        }

        set
        {
            switch (value)
            {
                case "Unchanged":
                    this.Entity.AcceptChanges();
                    break;

                case "Added":
                    break;

                case "Modified":
                    this.Entity.AcceptChanges();
                    this.Entity.es.RowState = DataRowState.Modified;
                    break;

                case "Deleted":
                    this.Entity.AcceptChanges();
                    this.Entity.MarkAsDeleted();
                    break;
            }
        }
    }

    public Employees Entity
    {
        get
        {
            if (this.entity == null)
            {
                this.entity = new Employees();
            }

            return entity;
        }

        set
        {
            this.entity = value;
        }
    }

    [NonSerialized]
    public Employees entity;

}

 

Now let's receive our Employees packet on the client, modify it, and send it back to the server.

 

EmployeesProxyStub proxy = call SomeMethod(); ...
Employees emp = proxy.Entity;  // grab the true Employees object now

emp.FirstName = "ES Rocks!";

call SendDataBackToClient(proxy);

 

The Server will now receive this XML packet. Notice that the esRowState is now Modified. The esRowState is interpreted in the set accessor of the proxy stub in the esRowState property to ensure that the entity is in the proper state after deserialization.

 

<Employees xmlns="http://tempuri.org/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <EmployeeID>257</EmployeeID>
    <LastName>Goo</LastName>
    <FirstName>ES Rocks!</FirstName>
    <esRowState>Modified</esRowState>
</Employees>

 

On the server you would deserialize just as we did on the client and then call Save(). Very simple. We are thinking of adding another checkbox in the template so that the proxy stubb class will only send dirty columns back when modified. For Deleted records only the primary key(s) are sent with an esRowState value of Deleted. Again, you can simply call save, no MarkAsDeleted() call is necessary, it's already been done for you.

From mobile devices to large scale enterprise solutions in need of serious transaction support, EntitySpaces can meet your needs. Whether you’re writing an ASP.NET application with medium trust requirements, or a Windows.Forms application, the EntitySpaces architecture is there for you. EntitySpaces is provider independent, which means that you can run the same binary code against any of the supported databases.EntitySpaces is available in both C# and VB.NET. EntitySpaces uses no reflection, no XML files, and sports a tiny foot print of less than 200k. Pound for pound, EntitySpaces is one tough, dependable .NET architecture.

The EntitySpaces Team
--

EntitySpaces LLC
Persistence Layer and Business Objects for Microsoft .NET
http://www.entityspaces.net

posted on Saturday, June 09, 2007 11:20:47 AM (Eastern Standard Time, UTC-05:00)  #   
 Friday, June 08, 2007

Venexus, Inc., a leading Business Service Provider, has released Venexus Search Engine 2.0, a new version of its full-blown search engine for web sites and portals that use the DotNetNuke Web Application Framework.

The latest release of Venexus Search also utilizes the new version of the EntitySpaces architecture, EntitySpaces 2007. EntitySpaces 2007 supports .Net Medium Trust operation. This opens the door for many users who may be using shared hosting and are currently limited by their hosting providers to medium trust environments. "EntitySpaces has allowed us to quickly absorb data schema changes and guarantees that our clients receive the quality software they demand through rigorous unit testing of both the EntitySpaces assemblies and generated code," said Scott Schecter, CTO of Venexus. "This flexibility has made EntitySpaces an invaluable tool in our development process, and is central to our agile methodologies."

Read the entire PR Newswire - Press Release ...

About Venexus, Inc.
Venexus, Inc. is a Business Service Provider (BSP) that develops and integrates business processes. Venexus provides a rare synthesis of "best of breed" technology, value-added offerings and highly desirable pricing to small and medium sized businesses throughout the United States. Venexus is a leading provider of DotNetNuke solutions and support. Venexus provides full lifecycle support of DotNetNuke with core competencies that include the planning, development, and implementation of DotNetNuke portals, skins, and modules.

For more information, please visit http://www.venexus.com

posted on Friday, June 08, 2007 11:21:56 AM (Eastern Standard Time, UTC-05:00)  #   
 Monday, June 04, 2007

CodeSmith and EntitySpaces 2008

EntitySpaces 2008 will greatly expand the reach of the EntitySpaces Architecture for the Microsoft .NET Framework by supporting both MyGeneration and CodeSmith. Our decision to support CodeSmith by no means indicates we are abandoning MyGeneration. MyGeneration will continue to be supported by EntitySpaces. We understand code generator loyalty, and we love MyGeneration. But, CodeSmith has its fervent followers, too. EntitySpaces 2008 will open up a new market for EntitySpaces and will give current EntitySpaces users a choice of generator.

As of EntitySpaces 2008, the EntitySpaces Architecture will be a very viable choice for the CodeSmith Community. Supporting CodeSmith will have the added advantage of allowing users to generate their EntitySpaces architecture(s) from within Visual Studio 2005 via CodeSmith’s Microsoft Visual Studio 2005 integration.

Supporting both MyGeneration and CodeSmith, as this post will outline, can be accomplished quite elegantly, and even allow for greater customization by the EntitySpaces Team.

One Architecture - Two Code Generators

The approach is straightforward. A master template will be created for each code generator. The master template will use the native user interface techniques of the given code generator to gather the user input. Next, the master template will launch the metadata sub-template which will extract the metadata using the MyGeneration MyMeta API or the CodeSmith SchemaExplorer API and create the EntitySpacesMetadata.xml file. The master template will then create an instance of the EntitySpacesPlugIn and populate it with the user’s selections and also provide it with a path to the EntitySpacesMetadata.xml file. Finally, the master template will launch a series of sub-templates just as EntitySpaces 2007 does now. The sub-templates will use only the EntitySpacesPlugIn which will run in both code generators. The only data the sub-templates will access will be the user input (which will be stored in our plug-in) and the intermediate metadata XML file. The sub-templates have no user interface nor will they call into the native code generator API. This approach will ensure that 90% or more of the code generation process will be the same regardless of what code generator is being used.

A few diagrams might help visualize how this will be accomplished.

 

 

The Metadata Sub-template creates the EntitySpacesMetadata.xml file which is then used, in conjunction with the EntitySpacesPlugin, by the common sub-templates.

 

 

Summary 

Our decision to support both MyGeneration and CodeSmith is not something that we have taken lightly. It has been seriously discussed for some time now. However, we did not want to cloud the EntitySpaces 2007 release with this announcement. Now, the time has come to let the cat out of the bag. However, EntitySpaces 2007 is by no means going to sit idle. We will be publishing a roadmap that will take ES2007 through the remainder of this year in just a few weeks. We can say now that hierarchical data binding and other very important features will make it into a follow on ES2007 release.

Move over .netTiers and make room for your new neighbor, EntitySpaces 2008.

From mobile devices to large scale enterprise solutions in need of serious transaction support, EntitySpaces can meet your needs. Whether you’re writing an ASP.NET application with medium trust requirements, or a Windows.Forms application, the EntitySpaces architecture is there for you. EntitySpaces is provider independent, which means that you can run the same binary code against any of the supported databases.EntitySpaces is available in both C# and VB.NET. EntitySpaces uses no reflection, no XML files, and sports a tiny foot print of less than 200k. Pound for pound, EntitySpaces is one tough, dependable .NET architecture.

The EntitySpaces Team
--

EntitySpaces LLC
Persistence Layer and Business Objects for Microsoft .NET
http://www.entityspaces.net

posted on Monday, June 04, 2007 6:32:40 AM (Eastern Standard Time, UTC-05:00)  #