Reputation: 907
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
Upvotes: 0
Views: 631
Reputation: 703
I was getting this error as well and the fix above was not fixing my issue but the latest build from GitHub does the trick.
I hope there is a release soon to fix up all these loose ends.
Upvotes: 0
Reputation: 1294
Any chance that you are using SQL Server Migration Assistant 2005 for Access? By default, the migration wizard adds timestamp columns to all tables with a data type of "timestamp." I recall that this field caused an exception similar (if not the same) as the one you are reporting when using SubSonic 3. You can disable the creation of the timestamp column via Tools > Default Project Settings > Add timestamp columns > Never.
Upvotes: 1
Reputation:
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.
Upvotes: 1