Project Description
Tesseract Data Access speeds up data access in .Net projects. Developed in C# .Net 4. It is a C#, class based ORM.

This project has been completely rewritten. You can find the new version here.

A data access base that allows the developer to use C# classes in an ORM setting. It utilizes reflection to retrieve the stored procedure name and stored procedure parameters from the calling method. It also matches the returned fields to the entity class.

There is one outstanding bug, however; when inserting an entity, the entity cannot inherit from any other class or the properties of that class will be picked up along with the entity properties and used as sproc parameters. I am currently working this out, but don't really have much time to spend on this.

I will upload a sample project when time permits.

Data Acccess Sample:

using System.Linq;
using System.Runtime.CompilerServices;
using Tesseract.DataAccess;
using Tesseract.DataAccess.Attributes;
using Tesseract.Services.Models.Image;

namespace Tesseract.Services.DAL
{
    [ConnectionName("Database")] //Optional. Specifies the connection string name (located in the config file). Defaults to 'DBConnection'.
    [SchemaName("WebService")] // Schema declaration is optional. Defaults to 'dbo'
    public class ImageAccess : DataAccessBase
    {
        [StoredProcedureName("Get_Image")] // Optional. Method name can match the stored procedure name
        [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] //Required. Prevents the compiler from optimizing out this method.
        public ImageModel GetImage(int WebsiteId, string Name) // Parameter names and types must match stored procedure parameter names and types
        {
            return ExecSelect<ImageModel>(WebsiteId, Name).FirstOrDefault(); // ImageModel represents the type you are expecting back. Parameter order must match the method signature
        }

        [StoredProcedureName("Del_Image")]
        [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
        public int DeleteImage(int ImageId)
        {
            return ExecDelete(ImageId);
        }

        [StoredProcedureName("Ins_Image")]
        [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
        public int InsertImage(ImageModel model)
        {
            return ExecInsert(model);
        }
    }
}


Entity Sample:

using Tesseract.DataAccess.Attributes;

namespace Tesseract.Services.Models.Image
{
    public class ImageModel
    {
        [IdentityColumn]
        public int ImageId { get; set; }

        public string Name { get; set; }

        [ColumnName("NativeScreenWidth")]
        public int Width { get; set; }

        [ColumnName("NativeScreenHeight")]
        public int Height { get; set; }

        public byte[] ImageBytes { get; set; }
    }
}

Last edited Feb 27, 2014 at 2:11 AM by robertschoenstein, version 4