R – Question getting started with SubSonic 3 + ActiveRecord

activerecordsubsonicsubsonic3

I am struggling pulling a simple list of records from one table object and printing them out.

I have a table called [Acceptance] that has four fields, two of which allow nulls. Here is the ddl for the schema object:

CREATE TABLE [dbo].[Acceptance](
    [AcceptanceID] [int] IDENTITY(1,1) NOT NULL,
    [AcceptanceCode] [nvarchar](2) NOT NULL,
    [AcceptanceDesc] [varchar](25) NOT NULL,
    [SortOrder] [tinyint] NOT NULL,
 CONSTRAINT [PK_Acceptance] PRIMARY KEY CLUSTERED 
(
    [AcceptanceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

When I try to render a single field of a single record to the console using the following code:

var a = Acceptance.All();
            Console.WriteLine(a.First().AcceptanceID);
            Console.Read();

I get the following exception:

System.ArgumentException was unhandled Message="Object of type 'System.Byte' cannot be converted to type 'System.Boolean'."

None of my fields are of type Bit/Boolean. I'm just not getting it…

Nullable types and Linq Query syntax are 2 topics that I am struggling with…

Any insight into how do this properly is greatly appreciated.

Thanks,

Josh

Best Answer

What DB are you using? I'm going to guess MySQL... you can go into the T4s and change the way the system type is defined. For the default template that's SQLServer.tt, with MySQL its MySQL.tt. Just look for where we set tinyint - it's an ongoing issue (with me at least) with returning byte[] vs bool - set as needed.