FastData is a simple and fast .NET micro ORM that can be used as ultra-fast data access layer of high-performance .NET projects.

To install FastData, run the following command in the Package Manager Console

PM> Install-Package FastData

Features

  • Supports the following databases
    • MS SQL Server 2005+
    • MS SQL Server Compact 4.0
    • Oracle
  • Caching with TableDependency
  • Lazy Executing
  • Asynchronous Executing with async and await

 

How to use

  • SELECT
    • syntax
      public IQueryable<T> Select<T>() ;
      
      public SelectQuery Select(params string[] fields);
      
    • sample
      using (var data = new DataAccess("test"))
      {
          List<User> users = data.Select<User>()
      .Where(u => u.Name.Contains("rahmat")) .OrderBy(u => u.UserName) .ToList(); List<User> users = data.Select("Id", "UserName", "Name") .From("User") .OrderBy("UserName") .Execute<User>().ToList(); DataTable users = data.Select("Id", "UserName", "Name") .From("User") .OrderBy("UserName") .ExecuteDataTable(); DataRow user = data.Select("Id", "UserName", "Name") .From("User") .Where("UserName", "rezaei") .ExecuteDataRow();

      IEnumerable<User> users = data.Query("select * from User")
      .Execute<User>(); }
  • INSERT
    • syntax
      public InsertQuery<T> Insert<T>(T entity);
      
      public InsertQuery Insert(string tableName);
      
    • sample
      using (var data = new DataAccess("test"))
      {
          User user = new User()
          {
              UserName = "rezaei",
              Name = "rahmat rezaei"
          };
          data.Insert<User>(user).Execute();
      
          data.Insert("User")
              .Field("UserName", "rezaei")
              .Field("Name", "rahmat rezaei")
              .Execute();
      
          var id = data.Insert("User")
                       .Field("UserName", "rezaei")
                       .Field("Name", "rahmat rezaei")
                       .ExecuteId();
      
      }
      
  • UPDATE
    • syntax
      public UpdateQuery<T> Update<T>(T entity);
      
      public UpdateQuery<T> Update<T>();
      
      public UpdateQuery Update(string tableName);
      
    • sample
      using (var data = new DataAccess("test"))
      {
          User user = new User()
          {
              Id = 1,
              UserName = "rezaei",
              Name = "rahmat rezaei"
          };
          data.Update<User>(user).Execute();
      
          data.Update<User>()
              .Set(u => u.Name, "rahmat rezaei")
              .Where(u => u.Id == 1)
              .Execute();
      
          data.Update("User")
              .Set("Name", "rahmat rezaei")
              .Where("Id", 1)
              .Execute();
      }
      
  • DELETE
    • syntax
      public DeleteQuery<T> Delete<T>(T entity);
      
      public DeleteQuery<T> Delete<T>();
      
      public DeleteQuery Delete(string tableName);
      
    • sample
      using (var data = new DataAccess("test"))
      {
          User user = new User()
          {
              Id = 1,
              UserName = "rezaei",
              Name = "rahmat rezaei"
          };
          data.Delete<User>(user).Execute();
      
          data.Delete<User>()
              .Where(u => u.Id == 1)
              .Execute();
      
          data.Delete("User")
              .Where("Id", 1)
              .Execute();
      }
      
  • Caching
    • syntax
      public static IQueryable<TSource> Cache<TSource>(this IQueryable<TSource> source, TimeSpan slidingExpiration);
      public static IQueryable<TSource> Cache<TSource>(this IQueryable<TSource> source, DateTime absoluteExpiration);
      public static IQueryable<TSource> CacheDependency<TSource>(this IQueryable<TSource> source, TableDependency tableDependency);
      public static IQueryable<TSource> CacheDependency<TSource>(this IQueryable<TSource> source, string tableName); public SelectQuery Cache(TimeSpan slidingExpiration); public SelectQuery Cache(DateTime absoluteExpiration);
      public SelectQuery CacheDependency(TableDependency tableDependency); public SelectQuery CacheDependency(string tableName);
    • sample
      List<User> users = data.Select<User>()
                             .OrderBy(u => u.UserName)
                             .Cache(TimeSpan.FromMinutes(10))
                             .CacheDependency("User")
                             .ToList();
      
      DataTable usersDataTable = data.Select("Id", "UserName", "Name")
                                     .From("User")
                                     .OrderBy("UserName")
                                     .Cache(TimeSpan.FromMinutes(10))
                                     .CacheDependency("User")
                                     .ExecuteDataTable();
      
  • Async
    • syntax
      public async Task<IEnumerable<T>> ExecuteAsync<T>();
      
      public async Task<DataTable> ExecuteDataTableAsync();
      
    • sample
      IEnumerable<User> users = await data.Select("Id", "UserName", "Name")
                                   .From("User")
                                   .OrderBy("UserName")
                                   .ExecuteAsync<User>();
      
      DataTable users = await data.Select("Id", "UserName", "Name")
                                  .From("User")
                                  .OrderBy("UserName")
                                  .ExecuteDataTableAsync();
      
  • Lazy
    • syntax
      public void ExecuteLazy();
      
      public int ExecuteLazyQueries();
      
    • sample
      for (int i = 0; i < 100; i++)
      {
          data.Insert("User")
              .Field("UserName", "user" + i)
              .Field("Name", "name" + i)
              .ExecuteLazy();
      }
      data.ExecuteLazyQueries();

Last edited May 9, 2013 at 1:20 PM by rahmatrezaei, version 11