Telling QuickDAL how your entity relates to table in a database is the hardest part.

Most basically, your classes will inherit from DataObject and provide the DataDefinition and configured QueryBuilder needed to relate the object to a table in the database. QuickDAL intentionally avoids reflection and aims for high flexibility, so these "configuration" objects live at the instance level.

For example

public class Order : DataObject<Order>
{
    public Guid OrderID { get; set; }
    public String Address { get; set; }
    /* etc. */

    // where the object lives
    public override QueryBuilder GetQueryBuilder()
    {
        return YOURNS.GetQueryBuilder();
    }

    // how the object relates to the schema
    public override DataDefinition GetDefinition()
    {
        return new DataDefinition()
        {
            DataEntity = "order",
            PrimaryKey = "orderID",
            Maps = new Dictionary<String, IReference>()
            {
                /* {"db-field-name", new Refrence<Type>(
                       // getter
                       () => LocalField,
                       // setter
                       (v) => LocalField = v
                )} */
                {"Address", new Reference<String>(() => Address, v => Address = v)},
                {"orderID", new Reference<Guid>(() => Id, v => Id = v)},
            }
        };
    }
}

If you build your schema in the database first, you can have your SQL Server generate much of this for you. See Generating definitions from the schema.

Once this is done, you can leverage the QuickDAL CRUD Methods on your Order entity.

To use other entities as query parameters, learn about Building Relationships.

Last edited Aug 7, 2014 at 2:24 AM by svidgen, version 4