Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

Building OpenPOS: Part 7 – NoSQL, MSSQL, SQL CE?

, 6 May 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Building OpenPOS: Part 7 – NoSQL, MSSQL, SQL CE?

One of the BIG overarching goals of OpenPOS is simplicity! You should be able to install OpenPOS using something like click-once and it should just work.

Simplicity? What’s wrong with Microsoft SQL Server Express, it’s simple?

If you are a developer, you would most probably have MSSQL installed, don't you? Well, my target audience might not? This makes the decision of which database to use slightly more complicated. I want to be able to choose…

By default, OpenPOS should use Microsoft SQL Compact 3.5… but if you need to scale, you can use Microsoft SQL Server 2008 R2! This is actually not as hard as it sounds? Linq-to-Sql supports both MSSQL and SQL CE out of the box by just changing the connection sting!

Never heard of SQL CE?

“Microsoft SQL Server Compact (SQL CE) is a compact relational database produced by Microsoft for applications that run on mobile devices and desktops. Prior to the introduction of the desktop platform, it was known as SQL Server for Windows CE and SQL Server Mobile Edition. The latest release is the SQL Server Compact 3.5 SP2 supporting .NET Framework 3.5 as well as Windows Mobile 2003, 5.0, 6.0, and 6.5. It includes both 32-bit and 64-bit native support. SQL CE targets occasionally-connected applications and applications with an embedded database. It is free to download as well as redistribute.”

By using SQL CE, I have NO dependency on any external software… It’s all in-process.

So, how does this work?

I “borrowed” Rob Conery’s ISession implementation

“It's all built around the notion of UnitOfWork and a "Session". If you like NHibernate - you'll feel good here. If you're a Linq to SQL fan, the Data Context is a Unit of Work. The idea is you work on some objects, the Session tracks the changes, then you commit at once. “

public interface ISession : IDisposable
{
    void CommitChanges();
    void Delete<T>(Expression<Func<T, bool>> expression) where T : class;
    void Delete<T>(T item) where T : class;
    void DeleteAll<T>() where T : class;
    T Single<T>(Expression<Func<T, bool>> expression) where T : class;
    System.Linq.IQueryable<T> All<T>() where T : class;
    void Add<T>(T item) where T : class;
    void Add<T>(IEnumerable<T> items) where T : class;
    void Update<T>(T item) where T : class;
}

And now I can use the  LinqToSqlSession:

// dataContext is a "normal" Linq-to-Sql DataContext
LinqToSqlSession session = new LinqToSqlSession(dataContext);

To use SQL CE:

string connectionString = "Data Source=OpenPOS.sdf";

And “Normal” MSSQL:

string connectionString = _
    "Data Source=.\\SQLEXPRESS;Initial Catalog=OpenPOS;Integrated Security=True;";

Nice and easy to use…

What about this new NoSQL “movement”?

The BIG advantage of “borrowing” Rob’s ISession is that I get out-of-the-box support for MongoDB… and it works!!!

“MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide rich queries and deep functionality).

MongoDB (from "humongous") is a scalable, high-performance, open source, document-oriented database. Written in C++, MongoDB features:”

If you want to learn more about NoSQL:

What is still on my TODO list: Printing, reporting, configuration & deployment are the BIG things still outstanding.

Here is the source.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

rudigrobler

South Africa South Africa
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.1411023.1 | Last Updated 6 May 2010
Article Copyright 2010 by rudigrobler
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid