ConnectionKeyAttribute [Mapping]

Estrusco edited this page May 2, 2016 · 1 revision
Clone this wiki locally

[namespace: Serenity.Data] - [assembly: Serenity.Data]

The ConnectionKey attribute sets the name of the connection to be used for I/O operations on the entity to which it is associated.

In this example the Product entity is associated with the Northwind connection key, that in the Web.config file is a DB connection string.

public sealed class ProductRow : Row, IIdRow, INameRow

In Web.config file:

    <add name="Default" connectionString="Data Source=(LocalDb)\MSSQLLocalDB; Initial Catalog=SereneTest_Default_v1; Integrated Security=True" providerName="System.Data.SqlClient" />
    <add name="Northwind" connectionString="Data Source=(LocalDb)\MSSQLLocalDB; Initial Catalog=SereneTest_Northwind_v1; Integrated Security=True" providerName="System.Data.SqlClient" />