This question is locked. New answers and comments are not allowed.
Hello,
OpenAccess: 2011.3.1129
Visual Studio: 2010
I try to use Open Access in Fluent Mapping mode with a base and derived classes, but OpenAccess gives me an error at runtime:
I tried to follow the instructions in Open Access help guide or from some topics of this forum about 'voa_keygen', but without success.
Structure of my SQL tables (SQL 2008):
Structure of the classes corresponding to the 2 table above, inherited from a base class (BaseObject):
I define the following code in the derived class of FluentMetadataSource in PrepareMapping() with horizontal inheritance for base class and derived classes:
All mentionned codes are in an assembly created by the project "Telerik OpenAccess Fluent Library" and this assembly is referenced in a asp.net web application.
When I call the function OpenAccessContext.GetAll(Of TestObject), Open Access gives me the error: Invalid object name 'voa_keygen.
What is wrong in my code that raises this error?
Notes:
1. If I uncomment the lines with "HasProperty... m_iID", Open Access gives me an error at runtime saying that m_iID doesn't exist.
2. If I uncomment the line "HasAssociation(...", Open Access gives me an error at compilation time: 'A property from the configured type does not take part in the expression'.
Thank you,
Alain
OpenAccess: 2011.3.1129
Visual Studio: 2010
I try to use Open Access in Fluent Mapping mode with a base and derived classes, but OpenAccess gives me an error at runtime:
Caused by: Invalid object name 'voa_keygen'. Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'voa_keygen'.
at Telerik.OpenAccess.RT.Adonet2Generic.Impl.StatementImp.executeQuery(String sql)
at OpenAccessRuntime.Relational.sql.HighLowRelationalKeyGenerator.IsCached(Connection con, RelationalKeyGeneratorInfoCache infoCache, String tab, String kCol, String vCol, String key, Boolean& ret)
at OpenAccessRuntime.Relational.sql.HighLowRelationalKeyGenerator.init(String className, RelationalTable theClassTable, Connection con, RelationalKeyGeneratorInfoCache relationalKeyGeneratorInfoCache)
I tried to follow the instructions in Open Access help guide or from some topics of this forum about 'voa_keygen', but without success.
Structure of my SQL tables (SQL 2008):
CREATE
TABLE
[Categories](
[ID] [
int
]IDENTITY(1,1)
NOT
NULL
,
[Title] [nvarchar](50)
NULL
,
CONSTRAINT
[PK_Categories]
PRIMARY
KEY
CLUSTERED
(
[ID]
ASC
)
WITH
(PAD_INDEX =
OFF
, STATISTICS_NORECOMPUTE =
OFF
, IGNORE_DUP_KEY =
OFF
, ALLOW_ROW_LOCKS =
ON
, ALLOW_PAGE_LOCKS =
ON
)
ON
[
PRIMARY
]
)
ON
[
PRIMARY
]
CREATE
TABLE
[dbo].[TestObjects](
[ID] [
int
] IDENTITY(1,1)
NOT
NULL
,
[Title] [nvarchar](44)
NOT
NULL
,
[CategoryID] [
int
]
NOT
NULL
,
CONSTRAINT
[PK_TestObjects]
PRIMARY
KEY
CLUSTERED
(
[ID]
ASC
)
WITH
(PAD_INDEX =
OFF
, STATISTICS_NORECOMPUTE =
OFF
, IGNORE_DUP_KEY =
OFF
, ALLOW_ROW_LOCKS =
ON
, ALLOW_PAGE_LOCKS =
ON
)
ON
[
PRIMARY
]
)
ON
[
PRIMARY
]
Structure of the classes corresponding to the 2 table above, inherited from a base class (BaseObject):
Public
MustInherit
Class
BaseObject
Private
m_iId
As
Integer
Public
Property
Id()
As
Integer
'(with m_iID field)
End
Class
Public
Class
Category
Inherits
BaseObject
Private
m_sTitle
As
String
Public
Property
Title()
As
String
'(with m_sTitle field)
End
Class
Public
Class
TestObject
Inherits
BaseObject
Private
m_nCategory
As
New
Category
Private
m_sTitle
As
String
Public
Property
Category()
As
Category
'(with m_nCategory field)
Public
Property
Title()
As
String
'(with m_sTitle field)
End
Class
I define the following code in the derived class of FluentMetadataSource in PrepareMapping() with horizontal inheritance for base class and derived classes:
Dim
nMappingConfigurations
As
List(Of MappingConfiguration) =
New
List(Of MappingConfiguration)()
Dim
nNamingRules
As
New
NamingRules()
nNamingRules.CaseMode = CaseChangeModes.PascalCase
nNamingRules.AddPrefix =
"m_n"
Dim
nBaseObjectMapping
As
MappingConfiguration(Of BaseObject) =
New
MappingConfiguration(Of BaseObject)()
nBaseObjectMapping.FieldNamingRules = nNamingRules
nBaseObjectMapping.MapType(
).Inheritance(InheritanceStrategy.Horizontal)
nBaseObjectMapping.HasProperty(
Function
(p) p.Id).HasFieldName(
"m_iId"
).IsIdentity(KeyGenerator.Autoinc).ToColumn("ID")
nMappingConfigurations.Add(nBaseObjectMapping)
Dim
nCategoryMapping
As
MappingConfiguration(Of Category) =
New
MappingConfiguration(Of Category)()
nCategoryMapping.FieldNamingRules = nNamingRules
nCategoryMapping.MapType().ToTable(
"Categories"
)
'nCategoryMapping.HasProperty(Function(p) p.Id).HasFieldName("m_iId").IsIdentity()
nCategoryMapping.HasProperty(
Function
(p) p.Title).HasFieldName(
"m_sTitle"
).ToColumn(
"Title")
nMappingConfigurations.Add(nCategoryMapping)
Dim
nTestObjectMapping
As
MappingConfiguration(Of TestObject) =
New
MappingConfiguration(Of TestObject)()
nTestObjectMapping.FieldNamingRules = nNamingRules
nTestObjectMapping.MapType().ToTable(
"TestObjects"
)
'nTestObjectMapping.HasProperty(Function(p) p.Id).HasFieldName("m_iId").IsIdentity()
nTestObjectMapping.HasProperty(
Function
(p) p.Title).HasFieldName(
"m_sTitle"
).ToColumn(
"Title")
'nTestObjectMapping.HasAssociation(Function(p) p.Category).HasConstraint(Function(p, c) p.Category.Id = c.Id).ToColumn(
"CategoryID")
nMappingConfigurations.Add(nTestObjectMapping)
All mentionned codes are in an assembly created by the project "Telerik OpenAccess Fluent Library" and this assembly is referenced in a asp.net web application.
When I call the function OpenAccessContext.GetAll(Of TestObject), Open Access gives me the error: Invalid object name 'voa_keygen.
What is wrong in my code that raises this error?
Notes:
1. If I uncomment the lines with "HasProperty... m_iID", Open Access gives me an error at runtime saying that m_iID doesn't exist.
2. If I uncomment the line "HasAssociation(...", Open Access gives me an error at compilation time: 'A property from the configured type does not take part in the expression'.
Thank you,
Alain