In simple applications, manually creating session objects is not required because most data store-specific actions can be performed by XPO using defaults (see XpoDefault.Session or Session.DefaultSession). If you are planning to use multiple data stores simultaneously or share the same Data Access Layer between multiple sessions, then sessions are the cornerstone of your application development.
Session allows you to either take control of data store specifics, such as the database name, user name and password, specified in the Session.ConnectionString property to connect to a data store or to use one of the existing connection objects to access a data source (see How to: Connect to a Data Store for details).
All the default settings for the default sessions being created can be customized using the XpoDefault object.
Your options for creating a session are:
Create a session programmatically.
Create a standalone session at design time. This option creates a session object on your form or a component whose properties you configure manually. This strategy is useful if you intend to set session properties at runtime or if you simply prefer setting the properties in the Properties window.
The sections below provide additional information on both these options.
Creating a Session at Runtime
The following code sample demonstrates how to create a new session with default settings.