Dofactory.com
Dofactory.com
 Back to list
Views:   9.9K
Replies:  1
Archived

Entity Framework versus Spark

Hi DoFactory team,


I propose Spark 4.5  framework to my senior developer. He is not quite convinced. 

There are two main reasons


1/ lack of user support for Spark framework compared to MS Entity Framework

2/ use raw SQL in SPARK (error will not be caught at compile time) compare to LINQ - Entity which is strongly-typed 

3/ Performance improvement, how can we prove this?

Please see his review below. Please provide some comments if you can


"

1. From DOFactory their website:


Does PRO Spark replace Entity Framework?

Yes, it does. We believe that PRO Spark is better suited to building applications that are faster and better.

Unlike the Entity Framework, Spark is easy to learn, light-weight, extremely fast, and you are always 100% in control of the SQL that executes on the database. Get ready to be impressed with the performance of your applications!

 

- easy to learn ?

we already know and use entity frameworks

ef benefits:

   mainstream microsoft product, well integrated into ms toolset, well supported, lots of discussions, problem workarounds, plenty support online

spark :

   cannot see any online discussions, support etc apart from dofactory website, much, much smaller user base == less support for problems

 

- light weight ?

not clear on the criteria for evaluating this. less lines of code ? smaller memory footprint ?


- extremely fast ?

perhaps, but we do not have performance issues with the type of apps we are dealing with currently - we are not handling hundreds of transactions/second.

this speed comes at a cost since the framework exposes 'raw sql' in the entity classes.

this sacrifices strongly typed queries (LINQ) on entities - see example below below.

if we have db performance issues (not expected), we will write db stored procs if/when required.

 

- you are always 100% in control of the SQL that executes on the database.

yes, but you give up this 'advantage' in order to get the productivity gains of ef

if performance ever becomes an issue, see above comments

 

 

2. spark demo sample code extract:

 

namespace Art.Web.Areas.Shop.Controllers

{

    public class CartController : BaseController

<...>

// line 254:

       // check if product already exists in cart

       var item = ArtContext.CartItems.Single(where: "CartId = @0 AND ProductId = @1", parms: new object[] { cart.Id, id });

 

 

query uses raw SQL generated using strings "CartId", "ProductId" - why no strong typing ?

These guys at Spark are still exposing raw SQL strings in the data access classes.

This is a major drawback, compared to ef strongly typed entities  and LINQ queries.

 

 

// compare to equivalent ef code :

       // check if product already exists in cart

       var item = ArtContext.CartItems.Where( x=> x.CartId == cart.Id && x.ProductId == id);

 

ef syntax is cleaner and simpler (my opinion) and STRONGLY TYPED (fact)

the obvious benefit is you get compile time errors instead of runtime errors when db schema changes.

 

 

3. To recap, I really see no benefits to using a third party tool like Spark with a small user base, proprietary code, dependent on a single manufacturer and giving up on the well supported microsoft ef.

Looking at the 'tool generated' project ( 2.Art.Domain) i see no extra value compared to what ef would provide.


"


Tony Wong, Apr 23, 2014
Reply 1
Hello Tony:

Everybody has their own reasons for selecting their preferred technologies. 

We stand by our position that SPARK is a better alternative to the Entity Framework.
SPARK is light weight (less than 1200 lines in its core code), simple, fast, and very easy to learn. 

To highlight its simplicity here is the entire API of the SPARK ORM:

interface IRepository<T>
{
   T Single(int? id);
   T Single(string where = null, params object[] parms);
   IEnumerable<T> All(string ids);
   IEnumerable<T> All(string where = null, string orderBy = null, ...);
   IEnumerable<T> Paged(out int totalRows, string where = null, ...);

   void Insert(T t);
   void Update(T t);
   void Delete(T t);

   object Scalar(string operation, string column, ...);
   int Count(string where = null, params object[] parms);
   object Max(string column = null, string where = null, params object[] parms);
   object Min(string column = null, string where = null, params object[] parms);
   object Sum(string column, string where = null, params object[] parms);

   IEnumerable<T> Query(string sql, params object[] parms);
   void Execute(string sql, params object[] parms);
}

It takes a .NET developer maybe 10 minutes to get up to speed.  Compare that to the complexity (and frequently the frustration) of the Entity Framework and the books that have been written about it.  

Finally,  I should mention that we use SPARK very successfully in all our own projects.

I hope this answers some of the issues you have raised. 
Jack
 
Jack Poorte, Apr 28, 2014
Cool - thank you to Glenn Long! Before I looked up this forum, I simply tried finding my botched network dir in my registry since I knew it was searching for it... but was nowhere within the registry...I assume part of my profile settings or something. Either way, install didn't work and thanks for the TARGETDIR msi reminder! :)
Apr 02, 2013
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.