DataSourceAttribute Kelas
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menentukan string koneksi, nama tabel, dan metode akses baris untuk pengujian berbasis data.
public ref class DataSourceAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false)]
public sealed class DataSourceAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class DataSourceAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)]
[System.Runtime.CompilerServices.Nullable(0)]
public sealed class DataSourceAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)]
public sealed class DataSourceAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false)>]
type DataSourceAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type DataSourceAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)>]
[<System.Runtime.CompilerServices.Nullable(0)>]
type DataSourceAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)>]
type DataSourceAttribute = class
inherit Attribute
Public NotInheritable Class DataSourceAttribute
Inherits Attribute
- Warisan
-
DataSourceAttribute
- Atribut
Contoh
[DataSource("Provider=SQLOLEDB.1; Sumber Data=sumber; Integrated Security=SSPI; Katalog Awal=EqtCoverage; Persist Security Info=False", "MyTable")] [DataSource("dataSourceNameFromConfigFile")].
Keterangan
- Ini hanya berfungsi pada .NET Framework dan tidak didukung pada .NET Core atau yang lebih baru.
- Berikut ini menunjukkan contoh penggunaan untuk atribut ini:
[DataSource("Provider=SQLOLEDB.1;Data Source=source;Integrated Security=SSPI;Initial Catalog=EqtCoverage;Persist Security Info=False", "MyTable")] [DataSource("dataSourceNameFromConfigFile")].
Konstruktor
| Nama | Deskripsi |
|---|---|
| DataSourceAttribute(String, String, String, DataAccessMethod) |
Menginisialisasi instans baru dari kelas DataSourceAttribute. Instans ini akan diinisialisasi dengan penyedia data, string koneksi, tabel data, dan metode akses data untuk mengakses sumber data. |
| DataSourceAttribute(String, String) |
Menginisialisasi instans DataSourceAttribute baru kelas. Instans ini akan diinisialisasi dengan string koneksi dan nama tabel. Tentukan string koneksi dan tabel data untuk mengakses sumber data OLEDB. |
| DataSourceAttribute(String) |
Menginisialisasi instans baru dari kelas DataSourceAttribute. Instans ini akan diinisialisasi dengan penyedia data dan string koneksi yang terkait dengan nama pengaturan. |
Bidang
| Nama | Deskripsi |
|---|---|
| DefaultDataAccessMethod |
Metode akses data default. |
| DefaultProviderName |
Nama penyedia default untuk DataSource. |
Properti
| Nama | Deskripsi |
|---|---|
| ConnectionString |
Mendapatkan nilai yang mewakili string koneksi untuk sumber data. |
| DataAccessMethod |
Mendapatkan metode yang digunakan untuk mengakses sumber data. |
| DataSourceSettingName |
Mendapatkan nama sumber data yang ditemukan di bagian <microsoft.visualstudio.qualitytools> di file app.config. |
| ProviderInvariantName |
Mendapatkan nilai yang mewakili penyedia data sumber data. |
| TableName |
Mendapatkan nilai yang menunjukkan nama tabel yang menyediakan data. |