Query fields mapping to SQL expressions (optional).
Namespace: NReco.DataAssembly: NReco.Data (in NReco.Data.dll) Version: 1.0.2
public IDictionary<string, string> FieldMapping { get; set; }
public IDictionary<string, string> FieldMapping { get; set; }
Public Property FieldMapping As IDictionary(Of String, String)
Get
Set
Public Property FieldMapping As IDictionary(Of String, String)
Get
Set
public:
property IDictionary<String^, String^>^ FieldMapping {
IDictionary<String^, String^>^ get ();
void set (IDictionary<String^, String^>^ value);
}
public:
property IDictionary<String^, String^>^ FieldMapping {
IDictionary<String^, String^>^ get ();
void set (IDictionary<String^, String^>^ value);
}
member FieldMapping : IDictionary<string, string> with get, set
member FieldMapping : IDictionary<string, string> with get, set
Property Value
Type:
IDictionary String,
String
Field mappings are useful for defining SQL-calculated columns, or resolving ambigious columns names:
var dbView = new DbDataView(
@"SELECT @columns FROM persons p
LEFT JOIN countries c ON (c.id=p.country_id)
@where[ WHERE {0}] @orderby[ ORDER BY {0}]") {
FieldMapping = new Dictionary<string,string>() {
{"id", "p.id"},
{"expired", "CASE WHEN DATEDIFF(dd, p.added_date, NOW() )>30 THEN 1 ELSE 0 END" }
}
} );
var dbView = new DbDataView(
@"SELECT @columns FROM persons p
LEFT JOIN countries c ON (c.id=p.country_id)
@where[ WHERE {0}] @orderby[ ORDER BY {0}]") {
FieldMapping = new Dictionary<string,string>() {
// just id is ambigious
{"id", "p.id"},
// SQL expression for calculated "expired" field
{"expired", "CASE WHEN DATEDIFF(dd, p.added_date, NOW() )>30 THEN 1 ELSE 0 END" }
}
} );