Friday, June 20, 2008
King Wilder posted Part Two of his ASP.NET MVC series and it's a very good read. Well done King. There are some very good comments at the end of his post as well.



King Wilder, is an ASP.NET developer who runs and owns a small web hosting company called Gizmo Beach. The article is about an ASP.NET MVC application that King ported to use EntitySpaces as the data access layer, or model. Here's a brief snippet from the article.





In Part 1 of this short series, I discussed how to build a simple ASP.NET MVC application using EntitySpaces.  If you have any Object Oriented background you will have noticed that that application was what is called, "tightly coupled".  That means that one set of objects depends on another.  This is generally a bad idea as it makes your application less flexible and extendable.

In this article, I will discuss what changes are necessary to make the application "loosely coupled", which in turn will make it easier to extend.


See the rest of the blog post HERE ...

posted on Friday, June 20, 2008 10:59:35 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Saturday, June 14, 2008

We've added support for CodeSmith and added many big new features including LINQ Support, subquery support, casting support, SQL 2008 support, NewSequentialID support, PostgreSQL Guid support, and just a ton of enhancements and fixes. We also now have a Microsoft SQL Server CE desktop provider as well as the Compact Framework provider. We didn't get everything done on the roadmap that we wanted to but we are well positioned for the future. We need to save some stuff for the official announcement so this is just a short and sweet post to let you know the official version "2008.1.0623.0".

Below are a few blog posts that speak to some of the new features coming in ES2008. And know for sure, we need you to run with our release candidate this week. So help us if you can.

EntitySpaces 2008 - LINQ to SQL in Next Beta

EntitySpaces 2008 - LINQ to SQL in Next Beta (Part 2)

EntitySpaces 2008 "Cast" Support

EntitySpaces 2008 - Dynamic SubQuery Showcase

EntitySpaces 2008 Adds Subqueries

 

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, a Mono application, 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 14, 2008 7:15:53 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Wednesday, June 11, 2008

We thought we would bring this blog post written by King Wilder to your attention. King Wilder, is an ASP.NET developer who runs and owns a small web hosting company called Gizmo Beach. The article is about an ASP.NET MVC application that King ported to use EntitySpaces as the data access layer, or model. Here's a brief snippet from the article.


ENTITY SPACES

Ok a brief word about Entity Spaces.  It is a really cool ORM tool but much more than that.  It reads your database and builds entity classes.  Now you might say that there are many tools that do that like NHibernate, SubSonic, etc., and you would be correct.  EntitySpaces actually costs money where SubSonic is free.  But I was using SubSonic before I trialed Entity Spaces.  After about a half a day playing with it, I purchased it and I'm going on my second year (2008) using it and I couldn't be happier.  Go to their web site to find out more.  But this article isn't about EntitySpaces, it's about building an ASP.NET MVC application without using Linq.

See the rest of the blog post HERE ...

posted on Wednesday, June 11, 2008 9:29:13 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]

The EntitySpaces 2008 Release Candidate is available now. Both the Developer and Trial Versions are available. Not all of the items on the roadmap are going to make the 1st ES2008 release. Those items listed on the roadmap not shown in red will be included in a follow on maintenance release. We are probably looking at less than two weeks before the official release so we encourage you to upgrade and try it out to make sure that there are no fixes that you need.


rc

Here is a short list of fixes and enhancements included in the Release Candidate:

  • esDataSource will automatically fetch the TotalRowCount if you do not set it
  • Added LINQ support too (optional template option)
  • Added source code for VistaDB and SqlCe MetadataEngine plugins to installer
  • Fixed some Casting issues
  • Fixed DatePart sub-operator for Oracle
  • Fixed CodeSmith generation error for SqlCe
  • Fixed CodeSmith generating un-compileable code for Oracle sequences
  • Fixed ordering issue with paging for Oracle
  • PostgreSQL Guid Support

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, a Mono application, 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 Tuesday, June 10, 2008 11:29:54 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Saturday, May 24, 2008
kick it on DotNetKicks.com

Okay, before you rail against the machine we are aware of the BINARY(16) thing-a-ma-joppy being implemented in the MySQL Connector/Net provider (5.2.2.0 version) but surely this is not the preferred method and is only a short term solution until MySQL 6.0 is released?  However, this post seems to indicate that the core MySQL database engine guys are perfectly happy not having a real Guid data type in the year 2008. Correct me if I'm wrong please ...

Basically, the MySQL Connector/Net (5.2.2.0) provider treats BINARY(16) columns as Guids, though there is not real Guid (uniqueidentifier in Microsoft SQL) data type. However, it's not transparent, there are special read and write methods for it. If you're a MySQL fan let the folks over at MySQL know that you want a true data type for Guids and not an imposter. We appreciate the hard work the MySQL Connector/Net team is doing. After all, MySQL doesn't have a Guid type yet so they are doing what they can. However, we would rather see them lobby the core database engine team for a true Guid column type. How about you?

Fans of MySQL unite, saddle up your dolphins and let MySQL know you want a true Guid datatype in MySQL 6.0.

posted on Saturday, May 24, 2008 10:49:39 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
kick it on DotNetKicks.com

I have always built architectures on top of ADO.NET DataTables, they're fast (yes), flexible, and the power it provides is really pretty good. Additionally, as new features are added to ADO.NET they can then be easily absorbed. We were able to add LINQ to SQL to EntitySpaces by simply turning a LINQ query into an ADO.NET DataTable. Once we exchange the LINQ query for an ADO.NET DataTable the EntitySpaces architecture functions as normal since its underlying data structure is a DataTable. Pretty sweet. Here's a nice little trick in case you are not aware of it.

DataContext context = new DataContext("User ID=sa;Initial Catalog=ForeignKeyTest;Data Source=localhost;");

var linqQuery = context.GetTable<Employee>().Where(s => s.LastName != "Griffin")
    .OrderBy(s => s.LastName);

SqlCommand cmd = context.GetCommand(linqQuery) as SqlCommand;

DataTable dataTable = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(dataTable);

There you have it. A DataTable obtained from a LINQ query, easy as pie.  You can simply ask the DataContext for a Command object and then use the Command object in combination with a DataAdapter to fill a DataTable. This is exactly what EntitySpaces 2008 does under the covers. This is an excellent way for architectures to leverage the power of LINQ to SQL.

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, a Mono application, 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, May 24, 2008 3:04:44 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Friday, May 23, 2008

EntitySpaces and Silverlight Demo

Part 2: Filtering and Changing EntitySpaces Data

kick it on DotNetKicks.com

Jon_Davis
Written by Jon Davis
http://www.jondavis.net/

 

 

Run the Demo Here  ==> http://developer.entityspaces.net/ES2008/Demos/Silverlight/PartTwo
Download the Source Here ==> http://www.developer.entityspaces.net/downloads/EntitySpacesSilverlightDemo2.zip 
 

Review of Part One

In Part One, I described the process of getting Silverlight to interact with a WCF web service, and I showed how I bound EntitySpaces based data objects (WCF client proxies) to Silverlight controls, specifically a DataGrid control. While there were a lot of pages of review in Part One, it was mostly point-and-click “configuration coding”, as MyGeneration, EntitySpaces, and Visual Studio did most of the work for me.

linqII_one

Figure 1 - EntitySpaces RIA running in Safari 3.1 (on Windows) with just about 20 lines of hand-written client-server code and XAML markup.

 

But showing data in a grid isn’t very exciting. It’s time to look at some interaction with data and give EntitySpaces a little more credit than just a data wrapper.

 

Category-Filtered Products (Client-Server Method)

Let’s assume that the user wants to filter the products list by category. I want to keep this demonstration as simple as possible, while proving out technical implementations of basic scenarios, so I’m not going to make any significant effort just yet to make this look pretty.

linqII_two  

Here’s the XAML:

<UserControl
    x:Class="EntitySpacesSilverlightDemo_Silverlight.Page"
    xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" 
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid x:Name="LayoutRoot" Background="Gray">
        <Grid.RowDefinitions>
            <RowDefinition Height="75" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0" Text="EntitySpaces on Silverlight ~ Northwind Demo" VerticalAlignment="Center" HorizontalAlignment="Center" />
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="Please Wait" Visibility="Collapsed" x:Name="WaitText" />
            <ListBox Width="300" Grid.Column="0" x:Name="ViewSelector" SelectionChanged="ViewSelector_SelectionChanged">
                <ListBoxItem Content="Products: All"></ListBoxItem>
            </ListBox>

            <Controls:DataGrid AutoGenerateColumns="True" x:Name="ESDataGrid" Grid.Column="1" />
        </Grid>
    </Grid>
</UserControl>

For starters and for the sake of continuing the discussion of ES over WCF, I’m going to make this a client-server filter—I’ll pass in a CategoryID as a parameter in my WCF request for products.

Here’s the complete client-side code-behind for Page.xaml.cs, additions in bold+brown:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Net;

using EntitySpacesSilverlightDemo_Silverlight.Northwind;

namespace EntitySpacesSilverlightDemo_Silverlight
{
    public partial class Page : UserControl
    {
        NorthwindClient.NorthwindClient ESNorthwind;

        public Page()
        {
            InitializeComponent();
            ESNorthwind = new NorthwindClient.NorthwindClient();

            ESNorthwind.GetCategoriesCompleted += ApplyCategoriesToList;
            ESNorthwind.GetProductsCompleted += new EventHandler<NorthwindClient.GetProductsCompletedEventArgs>(NorthwindClient_GetProductsCompleted);
            ESNorthwind.GetProductsByCategoryCompleted += new EventHandler<GetProductsByCategoryCompletedEventArgs>(Northwind_GetProductsByCategoryCompleted);

            GetCategories();

            LoadAllProducts();
        }

        private void GetCategories()
        {
            ESNorthwind.GetCategoriesAsync();
        }

        private void ApplyCategoriesToList(object sender, GetCategoriesCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                Categories[] cc = e.Result.Collection;
                for (int i = cc.Length-1; i >=0; i--)
                {
                    Categories category = cc[i];
                    ListBoxItem lbi = new ListBoxItem();
                    lbi.Tag = "CategoryID: " + category.CategoryID;
                    lbi.Content = "Products: " + category.CategoryName;
                    ViewSelector.Items.Insert(1, lbi);
                }
            }
        }

        private void LoadAllProducts()
        {
            WaitText.Visibility = Visibility.Visible;
            ESNorthwind.GetProductsAsync();
        }

        void LoadProductsByCategory(int categoryId)
        {
            WaitText.Visibility = Visibility.Visible;
            ESNorthwind.GetProductsByCategoryAsync(categoryId);
        }

        void Northwind_GetProductsByCategoryCompleted(object sender, GetProductsByCategoryCompletedEventArgs e)
        {
            WaitText.Visibility = Visibility.Collapsed;
            ProductsCollection pc = e.Result;
            ESDataGrid.ItemsSource = pc.Collection;
        }

        void NorthwindClient_GetProductsCompleted(object sender, Northwind.GetProductsCompletedEventArgs e)
        {
            WaitText.Visibility = Visibility.Collapsed;
            ProductsCollection pc = e.Result;
            ESDataGrid.ItemsSource = pc.Collection;
            ESDataGrid.Columns[ESDataGrid.Columns.Count - 1].Visibility = Visibility.Collapsed; // hide "esRowState"
        }

        private void ViewSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBoxItem lbi = ViewSelector.SelectedItem as ListBoxItem;
            if (lbi != null)
            {
                if (lbi.Content.ToString() == "Products: All")
                {
                    LoadAllProducts();
                    return;
                }
                string tag = lbi.Tag as string;
                if (tag != null && tag.StartsWith("CategoryID: "))
                {
                    tag = tag.Substring(12);  // length of "CategoryID:"
                    LoadProductsByCategory(int.Parse(tag));
                }
            }
        }

    }
}

On the server, we will perform a basic EntitySpaces query operation.

INorthwind service interface:
[ServiceContract]
public interface INorthwind
{
    [OperationContract]
    ProductsCollectionProxyStub GetProducts();

    [OperationContract]
    ProductsCollectionProxyStub GetProductsByCategory(int categoryId);
    [OperationContract]
    CategoriesCollectionProxyStub GetCategories();
}

Northwind service implementation:
public class Northwind : INorthwind
{
    public ProductsCollectionProxyStub GetProducts()
    {
        ProductsCollection pc = new ProductsCollection();
        pc.LoadAll();
        ProductsCollectionProxyStub pcs = new ProductsCollectionProxyStub(pc);
        return pcs;
    }

    public ProductsCollectionProxyStub GetProductsByCategory(int categoryId)
    {
        ProductsCollection pc = new ProductsCollection();
        pc.Query.Where(pc.Query.CategoryID.Equal(categoryId));
        pc.Load(pc.Query);

        ProductsCollectionProxyStub pcs = new ProductsCollectionProxyStub(pc);
        return pcs;
    }

    public CategoriesCollectionProxyStub GetCategories()
    {
        CategoriesCollection cc = new CategoriesCollection();
        cc.LoadAll();

        // strip out the OLE bitmaps
        for (int i = 0; i < cc.Count; i++)
        {
            cc[i].Picture = null;
        }

        CategoriesCollectionProxyStub ccs = new CategoriesCollectionProxyStub(cc);
        return ccs;
    }

}

Category-Filtered Products (Local Filtering Method)

Practically speaking, calling out to the server every time you want to filter the products is bad design unless the Products list contains a lot (hundreds of thousands) of records, in which case we should also drop the “Products: All” unfiltered option from the ListBox so that the user cannot make the mistake of loading all products which might take forever.

If the unfiltered source data is relatively small, as Northwind’s Products table actually is, then it would make more sense to load all products from the server and then filter against the category locally. This eliminates the HTTP-based callback to the server and makes the user’s experience much faster and more responsive.

LINQ-to-Objects is supported in Silverlight, and this includes LINQ-to-EntitySpaces-client-proxies. We can change the NorthwindClient_GetProductsCompleted and ViewSelector_SelectionChanged methods to use LINQ filtering rather than server-side filtering. In so doing, we can remove much of the code we just added and achieve the same results but executing much faster.

Products[] NorthwindProducts = null;
void NorthwindClient_GetProductsCompleted(object sender, Northwind.GetProductsCompletedEventArgs e)
{
    WaitText.Visibility = Visibility.Collapsed;
    NorthwindProducts = e.Result.Collection;
    ESDataGrid.ItemsSource = NorthwindProducts;
    ESDataGrid.Columns[ESDataGrid.Columns.Count - 1].Visibility = Visibility.Collapsed; // hide "esRowState"
}

private void ViewSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    ListBoxItem lbi = ViewSelector.SelectedItem as ListBoxItem;
    if (lbi != null)
    {
        if (lbi.Content.ToString() == "Products: All")
        {
            ESDataGrid.ItemsSource = NorthwindProducts;
            ESDataGrid.Columns[ESDataGrid.Columns.Count - 1].Visibility = Visibility.Collapsed; // hide "esRowState"
            return;
        }
        string tag = lbi.Tag as string;
        if (tag != null && tag.StartsWith("CategoryID: "))
        {
            int catID = int.Parse(tag.Substring(12));
            ESDataGrid.ItemsSource =
                from p in NorthwindProducts
                where p.CategoryID == catID
                select p;
            ESDataGrid.Columns[ESDataGrid.Columns.Count - 1].Visibility = Visibility.Collapsed; // hide "esRowState"
        }
    }
}

We can now eliminate one of the INorthwind interfaces we just added, ..

  • GetProductsByCategory(int categoryId)

.. and we can eliminate some of the just-added client/server handling code in Silverlight:

  • LoadProductsByCategory(int categoryId)
  • Northwind_GetProductsByCategoryCompleted(...)

Changing Data

Let’s assume that the user is an administrator who is maintaining this list of products and needs to be able to make changes to product data on the fly. The bad news is that in the interest of focusing on EntitySpaces and less on Silverlight UI, I intended to refrain from creating a pop-up editor for editing a record. The good news is that the Silverlight DataGrid supports two-way databinding and inline edits, and in such case one would need no layout changes at all. I only need to add an event handler for DataGrid edits and pass the revised record up to the server via WCF.

We’ll bind to the CommittingCellEdit and CommittingRowEdit events. In CommittingCellEdit we’ll update the property that was edited, and in CommittingRowEdit we’ll pass the Product out to the server.

Page.xaml (modify):

<Controls:DataGrid AutoGenerateColumns="True" x:Name="ESDataGrid" Grid.Column="1"
CommittingCellEdit="ESDataGrid_CommittingCellEdit"
CommittingRowEdit="ESDataGrid_CommittingRowEdit"
/>

Page.xaml.cs (add):

private void ESDataGrid_CommittingCellEdit(object sender, DataGridCellCancelEventArgs e)
{
    Products p = (Products)e.Row.DataContext;
    string f = e.Column.Header.ToString();
    string v = ((TextBox)e.Element).Text;
    System.Reflection.PropertyInfo pi = p.GetType().GetProperty(f);
    if (pi.PropertyType == typeof(string))
    {
        pi.SetValue(p, v, null);
    }
    else if (pi.PropertyType == typeof(int) ||  pi.PropertyType == typeof (int?))
    {
        pi.SetValue(p, int.Parse(v), null);
    }
    else e.Cancel = true;
    if (!e.Cancel)
    {
        p.esRowState = "Modified";
    }
}

private void ESDataGrid_CommittingRowEdit(object sender, DataGridRowCancelEventArgs e)
{
    Products p = (Products)e.Row.DataContext;
    if (p.esRowState == "Modified")
    {
        ESNorthwind.UpdateProductAsync(p);
    }
}

This won’t compile until we revise our service in the Web project and then update the reference to it in the Silverlight project.

INorthwind.cs (add):

[OperationContract]
void UpdateProduct(ProductsProxyStub product);

AppCode/Northwind.cs (or Northwind.svc.cs, add):

public void UpdateProduct(ProductsProxyStub product)
{
    Products prod = (Products)product.GetEntity();
    prod.Save(); // wow, that was easy..
}

Silverlight project:

linqII_three

Now the Silverlight code should compile, and if you set breakpoints both on the server’s UpdateProduct() method as well as on the new event handler in Silverlight, you should be able to watch the data model as it gets updated and sent back to the server.

Recommitting back to the server was so easy (although the reflection bits in the CommitingCellEdit event handler needs some clean-up) it’s actually a little dangerous. We can’t go live with this change on a public demo without having a nightly automated process to restore the Northwind data or else it will become unusable.

But this tutorial should have still sufficed in getting you on your feet with fetching, filtering, and updating data between Silverlight and EntitySpaces. There is a lot of design-related knowledge to be had in Silverlight, and real-world business objects to be realized in EntitySpaces, but this was a basic data discussion, so the rest is up to you.

 


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, a Mono application, 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 Friday, May 23, 2008 10:15:53 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Sunday, May 11, 2008

Oh, I almost forgot the most important thing. And that is using LINQ to SQL to populate data directly into your EntitySpaces collections, oh man this is hot !!

DataContext context = new DataContext("User ID=sa;Initial Catalog=Northwind;Data Source=localhost;");

var linqQuery = context.GetTable<Employees>().Where(s => s.LastName == "Griffin")
    .OrderBy(s => s.LastName);

EmployeesCollection coll = new EmployeesCollection();
coll.Load(context, linqQuery);

foreach (Employees emp in coll)
{
    Console.WriteLine(emp.FirstName);
}

Notice that we pass the context and the linqQuery directly into our EntitySpaces EmployeeCollection's Load() method, the rest is the same as usual, awesome !!

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, a Mono application, 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 Sunday, May 11, 2008 10:37:53 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]

Although this didn't make our Beta III release our LINQ support is already in the new templates for the next Beta (we're getting close to a final beta but not yet). Before we show you how it all works let's look at some examples to peak your interest.

First lets select all Employees who have the last name "Griffin" and order them as well. The Employees class highlighted in blue above is your true EntitySpaces class.

DataContext context = new DataContext("User ID=sa;Initial Catalog=Northwind;Data Source=localhost;");

var q = context.GetTable<Employees>().Where(s => s.LastName == "Griffin")
    .OrderBy(s => s.LastName);

foreach (Employees emp in q)
{
    Console.WriteLine(emp.LastName);
}

Now let's do a join using a different syntax style. Notice that we select the EmployeeID from the Empoyees table and the OrderID from the Orders table.

DataContext context = new DataContext("User ID=sa;Initial Catalog=Northwind;Data Source=localhost;");

var employees = context.GetTable<Employees>();
var orders = context.GetTable<Orders>();

var query = from e in employees
            join o in orders on e.EmployeeID equals o.EmployeeID
            where e.LastName != "Griffin"
            select new { e.EmployeeID, o.OrderID };

foreach (var obj in query)
{
    Console.WriteLine(obj .EmployeeID.ToString() + ":" + obj .OrderID.ToString());
}

To add LINQ to SQL support to your EntitySpaces classes all you need to do is check a checkbox on the advanced tab.

When you check this checkbox the templates will make sure our LINQ to SQL support is injected in your classes. The code ends up looking like this.

[Serializable]
[Table(Name = "Employees")]
public partial class Employees : esEmployees
{
    #region LINQtoSQL overrides

    [Column(IsPrimaryKey = true, CanBeNull = false)]
    public override System.Int32? EmployeeID
    {
        get { return base.EmployeeID; }
        set { base.EmployeeID = value; }
    }

    [Column(IsPrimaryKey = false, CanBeNull = false)]
    public override System.String LastName
    {
        get { return base.LastName; }
        set { base.LastName = value; }
    }

    [Column(IsPrimaryKey = false, CanBeNull = false)]
    public override System.String FirstName
    {
        get { return base.FirstName; }
        set { base.FirstName = value; }
    }

    [Column(IsPrimaryKey = false, CanBeNull = true)]
    public override System.String Title
    {
        get { return base.Title; }
        set { base.Title = value; }
    }

    // and so on ....

    #endregion
}

Of course you will need to be targeting .NET 3.5 and the generated classes will include these additional namespaces:

using System.Data.Linq;
using System.Data.Linq.Mapping;

This will work for any .NET Providers that support LINQ to SQL, currently I believe that is only Microsoft's SQL Client (but I could be wrong, I know the Npgsql guys are working on this too). So, now you can have all of the wonderful EntitySpaces features, including our Dynamic API (which runs on all of our supported databases and .NET 2.0) and LINQ as well if you so choose.

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, a Mono application, 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 Sunday, May 11, 2008 8:03:39 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 Saturday, May 10, 2008

 

We're less than one week away from the EntitySpaces 2008 presentation. 


Indy ALT.NET, a Technical Presentation of EntitySpaces 2008

The first meeting of the Indy ALT.NET community group will be May 15. Mike Griffin of EntitySpaces will be giving an in-depth technical presentation on EntitySpaces 2008 in Indianapolis. Pizza will be served and the presentation will start at 6pm. We expect this developer oriented technical presentation to go a couple of hours so drop in anytime after work. There will be Q&A time as well.

Registration:
You must register for this event. Space is limited to 70 individuals.
Where:
Country Inn & Suites By Carlson Indianapolis North
9797 North Michigan Road
Indianapolis, IN 46032
317-876-0333

MAP
When:
Doors open at 5pm with the presentation starting at 6pm. Get there at 5 for pizza!


Mike from EntitySpaces will be demonstrating their new Subquery and Casting support, their powerful Proxy support including running EntitySpaces under Silverlight, database independence, LINQ to SQL and more ...

 


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, a Mono application, 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, May 10, 2008 10:59:21 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]