Here we didn't have to open the connection, as List extension method opens it automatically. This corresponds to SqlConnections.NewByKey("Northwind"). When you are going to query for customers, instead of hardcoding "Northwind", you may reuse this information from a CustomerRow: using ( var connection = SqlConnections.NewFor()) Public sealed class CustomerRow : Row, IIdRow, INameRow Looking on top of a Row class, you may spot ConnectionKey attribute generated by Sergen: If you don't want to memorize connection string keys, but instead reuse information on a row (in form of a ConnectionKey attribute), you may prefer this variant. You usually don't have to open connections explicitly as they are automatically opened when needed (as long as you use Serenity extensions). For example, if ProviderName is "" this creates a new SqlConnection object. This reads connection string with "Default" key from web.config, and creates a new connection using ProviderName information that is also specified in connection setting. Try to always wrap connections in a using block. using ( var connection = SqlConnections.NewByKey( "Default")) Use this method to get a new IDbConnection for a connection string defined in application configuration file (e.g. SqlConnections.NewByKey method public static IDbConnection NewByKey( string connectionKey) This class contains static functions to create a connection, and control it in a database agnostic way. It provides some basic helpers to create a connection, add parameters, execute queries etc. Serenity uses simple ADO.NET data access objects, like SqlConnection, DbCommand etc. Using Local Cache and Distributed Cache In Sync Upgrade to Serenity 2.0 and Enable TypeScript Remove Northwind & Other Samples From SereneĪuthenticate With Active Directory or LDAP ![]() Hiding the Tenant Administration PermissionĮxtending Multi-Tenant Behavior To Northwind Preventing Edits To Users From Other Tenants Instaling Serene Asp.Net Core Version with Serin Installing Serene Directly From Visual Studio ![]() Installing Serene From Visual Studio Marketplace
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |