I hope there is a very simple explanation why I get this error.
I am using S # arpArcitecture 1.6. on a 64-bit installation of Windows 7.
Line 3 of the following code gives an error:
{"An identifier of the wrong type is provided. Expected: System.String, received by System.Guid"} System.Exception {NHibernate.TypeMismatchException}
1 public Category GetCategory(Guid id)
2 {
3 Category cat = categoryRepository.Get(id);
4 return cat;
5 }
Supporting information
Table (SQL Server 2008)
CREATE TABLE [dbo].[MasterCategories] (
[masterCategoryId] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[organizationId] [nchar](5) NOT NULL,
[categoryNumber] [nvarchar](25) NOT NULL
)
Entity definition
public class Category : EntityWithTypedId<Guid>
Free match
public void Override(AutoMapping<Category> mapping)
{
mapping.Table("MasterCategories");
mapping.Id(x => x.Id).Column("masterCategoryId");
mapping.Map(x => x.Number).Column("categoryNumber");
mapping.References(x => x.Organization)
.Column("organizationId")
.Cascade.All();
}
Repository interface
public interface ICategoryRepository : IRepositoryWithTypedId<Category,Guid>
{
}
Repository
public class CategoryRepository :
RepositoryWithTypedId<Category,Guid>,
ICategoryRepository
{ }
source
share