Mindscape
  • Register
  • Login
  • YOUR CART IS EMPTY
home
Software
  • Developers Toolbox
  • LightSpeed
  • Raygun
  • WPF Elements
  • Web Workbench
  • Metro Elements
  • Silverlight Elements
  • NHibernate Designer
  • Phone Elements
  • WPF Diagrams
  • Simple DB management
  • Visual Tools for SharePoint
Downloads
Store
  • Buy online
  • Purchase order
  • Volume discounts
  • Reseller
  • Software license
  • Contact sales
Blog
Support
About
  • About Us
  • Contact
  • Testimonials
rss
twitter
facebook
Working with Database Providers DB2 Firebird MySQL Oracle PostgreSQL SimpleDB SQL Server Compact Azure Table Service VistaDB 4 Windows Azure Table Service SQL Server SQLite VistaDB Low Level Database Access

Low Level Database Access

It is sometimes useful to send SQL commands directly to a database, or for other reasons to drop down to ADO.NET.  LightSpeed supports this through the IDataProviderObjectFactory interface and IUnitOfWork.PrepareCommand and FindBySql methods.

Creating ADO.NET Objects with LightSpeed

The LightSpeedContext.DataProviderObjectFactory property returns an IDataProviderObjectFactory for the context’s data provider.  You can use this to create ADO.NET connection, command and command parameter objects suitable to the database in use.

Note that connection objects are not automatically initialised with the context connection string.

Using ADO.NET Objects with LightSpeed

To associate an ADO.NET command with the connection and transaction of a unit of work, call IUnitOfWork.PrepareCommand.  This does not execute the command – you must still call ExecuteReader, ExecuteScalar or ExecuteNonQuery – but it prepares the command to run over the unit of work’s connection, and enrols it in the unit of work’s transaction if one is in progress.

If you want to materialise the results of a SQL command as entities, call IUnitOfWork.FindBySql.  In this case, the results of the command must include an Id column.

Data Products

  • LightSpeed ORM
  • NHibernate Designer
  • SimpleDB Tools
  • SharePoint Tools

DevOp Tools

  • Raygun

Visual Controls

  • WPF Elements
  • WPF Diagrams
  • Silverlight Elements
  • Phone Elements

Popular Products

  • Web Workbench

    Modern web development for Visual Studio!

  • Mindscape Megapack

    All Mindscape products for one awesome price!

Quick Links

  • Forums
  • Blog
  • Register
  • Login
  • Contact us
  • Twitter
  • Facebook
  • Google+
  • YouTube
  • Linkedin
  • Rss

© Mindscape 2025. Mindscape is a registered trademark of Mindscape Limited.

  • Terms
  • Privacy