Mimer SQL Data Provider
Basic select
Mimer SQL Data Provider > Overview > Working with user defined types > Basic select

When retrieving data from the database user defined types are returned from the database server. This can be done with the  MimerUserDefinedType class. Consider the following SQL types and table:

SQL Schema
Copy Code
create type streetno as integer;
create type address as (street varchar(30), streetnumber streetno);
create table person(personid int, home address);

And the following code:

MimerConnection conn = new MimerConnection(connectionString);
try {
MimerCommand comm1 = new MimerCommand("select * from person", conn);
// Create a data reader to retrieve the rows from the database
MimerDataReader reader = comm1.ExecuteReader();
     while (reader.Read()) {
          int personsId = reader.GetInt32(0);
     MimerUserDefinedType personsHome = reader.GetUserDefinedType(1);
          //  We can access each part of the user defined type through an indexer on personsHome
          string streetname = (string) personsHome[0];

          int streetnum = (int) personsHome[1];
          //  Work with data...

In the example the data from the user defined type column home is retrieved into the variable personsHome. The individual elements of the user defined type are then accessed through the indexer of the type. The indexer returns an instance of type object, so therefore a cast is used for each assignment.

See Also

Basic insert
Selecting user defined type into application class
Inserting user defined type from application class