ColumnMapping to properties of an class object
-
I have a class like so:
public class BaseRef
{
public int id {get; set;}
public string listID {get; set;}
public string Name {get; set;}
}And have a data column that is of type BaseRef that I added to a DataTable:
this.Columns.Add(new DataColumn("ParentRef", typeof(BaseRef)));
I am using OdbcDataAdapter to get a query, but in this case my query has three separate columns for the id, listID and Name fields of the Parent:
SELECT id, listID, Name FROM ParentTable
I tried to setup a DataAdapterTableMapping and add ColumnMappings, but it doesn't appear that I can map a source column to a property of a class column. I tried:
mapping.ColumnMappings.Add("id", "ParentRef.id");
mapping.ColumnMappings.Add("listID", "ParentRef.listID");
mapping.ColumnMappings.Add("Name", "ParentRef.Name");Is there a way to get the mapping to map to the properties of my class?
-
I have a class like so:
public class BaseRef
{
public int id {get; set;}
public string listID {get; set;}
public string Name {get; set;}
}And have a data column that is of type BaseRef that I added to a DataTable:
this.Columns.Add(new DataColumn("ParentRef", typeof(BaseRef)));
I am using OdbcDataAdapter to get a query, but in this case my query has three separate columns for the id, listID and Name fields of the Parent:
SELECT id, listID, Name FROM ParentTable
I tried to setup a DataAdapterTableMapping and add ColumnMappings, but it doesn't appear that I can map a source column to a property of a class column. I tried:
mapping.ColumnMappings.Add("id", "ParentRef.id");
mapping.ColumnMappings.Add("listID", "ParentRef.listID");
mapping.ColumnMappings.Add("Name", "ParentRef.Name");Is there a way to get the mapping to map to the properties of my class?