How to specify the Database Name (LINQ to SQL)

Source: Internet
Author: User

Barefoot Learning

In the previous demonstration, whether it is about how to generate an external XML ing file, a dbml file, and verifying the two files, this includes the previous demo about how to serialize object class objects in the object model, which is a question about how to create an object model. However, in these demos, we focus on how to use tools to create object models, whether using sqlmetal or object relationship designer. The following demos will help you see how to use them.CodeEditor custom object model ......

UseDatabaseattributeYou can specify the name of a database when no name is provided for a connection.
You can apply the databaseattribute feature to any strong type.DatacontextStatement.
This information is used only when no database name is specified for the connection.
The databaseattribute feature is optional. If you use this feature, you must useNameAttribute to provide a name. If this feature is not applied and the connection name is not specified, it is assumed that the database has the same name as the datacontext class.

Sample Code

[Database (name = "northwind")] public partial class northwinddatacontext: system. Data. LINQ. datacontext {}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.