KREDOR Business Object Framework Documentation

NamingConventionsAttribute Class

Specifies the naming conventions for tables and stored procedures.

For a list of all members of this type, see NamingConventionsAttribute Members.

System.Object
   Attribute
      NamingConventionsAttribute

public class NamingConventionsAttribute : Attribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

The default is no preffix and "_sel,_ins,_upd,_del" for suffixes. Thus for a class called Account the framework by default will look for stored procedures named Account_sel, Account_ins, Account_upd, Account_del. If such are not found the framework will use dynamically generated parameterized queries for CRUD operations based on the corresponding table or view. Since these queries are not "dynamic sql" your system is protected from sql injection attacks. They are also compiled and cached on the server thanks to a feature of Sql Server called Auto-Parameterization and performancewise they are approximately equivalent to stored procedures. Since manually creating stored procedures is error prone, if you must use stored procedures, use the option in the Business Class Item Wizard to generate an sql stored procedures script in addition to the class file. NOTE: If you are manually writing insert or update stored procedures, these should end with a SELECT statement selecting any values that have changed in the insert or update operation and need to be reflected in the corresponding .NET object. For insert operations these are the identity column, any computed columns and any columns with defaults. For update operations these are any computed columns. For example in the simplest case an insert stored procedure should end with a statement similar to: SELECT SCOPE_IDENTITY() AS AccountID

Example

This sample shows a base class for business classes bound to database MyDatabase decorated with the NamingConventionsAttribute.

[DataSource("MyDatabase")]
[NamingConventions(TablePrefix = "tbl_",
                SelectStoredProcedurePrefix = "sp_", SelectStoredProcedureSuffix = "_ins",
                InsertStoredProcedurePrefix = "sp_", InsertStoredProcedureSuffix = "_ins",
                UpdateStoredProcedurePrefix = "sp_", UpdateStoredProcedureSuffix = "_upd",
                DeleteStoredProcedurePrefix = "sp_", DeleteStoredProcedureSuffix = "_del")]
public class DbMyDatabase : BusinessObject
{
    public Account() : base ()
    {
    }

    protected override void OnLoad()
    {
    }
}

Requirements

Namespace: Kredor.BO

Assembly: KREDOR.BOFramework (in KREDOR.BOFramework.dll)

See Also

NamingConventionsAttribute Members | Kredor.BO Namespace | SchemaAttribute | BusinessObject