My problem: When using this extension it only maps up the ID value from the database to class object.
So I'm curious how do i make it map the other values?
C# Mapper
public class SoftwareReleaseTypeHandle : SqlMapper.TypeHandler<SoftwareRelease>
{
public override SoftwareRelease Parse(object value)
{
if (value == null || value is DBNull)
{
return null;
}
SoftwareRelease rel = new SoftwareRelease();
rel.ID = (Guid)value;
return rel;
}
public override void SetValue(IDbDataParameter parameter, SoftwareRelease value)
{
parameter.DbType = DbType.Guid;
parameter.Value = value.ID.ToString();
}
}
The SQL table looks like this:
CREATE TABLE [dbo].[SoftwareRelease](
[ID] [uniqueidentifier] NOT NULL,
[Type] [tinyint] NOT NULL,
[ReleaseType] [tinyint] NOT NULL,
[Version] [nchar](30) NOT NULL,
[ZipFile] [varbinary](max) NOT NULL,
[Date] [datetime] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
The reason i used this mapper was so in other places in my code i could do, and it would automaticly get mapped up:
class MyInstallation
{
public string Bla;
public string BlaBla;
SoftwareRelease MyInstallation;
}
And when i then use Dapper to get from a table that looks like.
CREATE TABLE [dbo].[MyInstallation](
[ID] [uniqueidentifier] NOT NULL,
[Bl] [nchar](30) NOT NULL,
[BlaBla] [nchar](30) NOT NULL,
[MyInstallation] [uniqueidentifier] NOT NULL,
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]