我的模型包含以下枚举和实体:
<cf:enumeration name="Language" usePersistenceDefaultValue="false">
<cf:enumerationValue name="EN" value="1" default="true" />
<cf:enumerationValue name="NL" value="2" />
<cf:enumerationValue name="DE" value="3" />
</cf:enumeration>
<cf:entity name="Person" >
<cf:property name="Id" key="true" />
<cf:property name="Languages" typeName="CodeFluent.Runtime.Utilities.PersistentList<Language>">
<cf:message class="_doc">The languages that the person speaks</cf:message>
</cf:property>
<cf:method name="LoadPersonThatSpeaksOneOrMoreLanguages" checkLevel="None" memberAttributes="Public" >
<cf:body language="tsql" text="load(Language[] languages) from Person where Languages in (@languages)" />
</cf:method>
</cf:entity>
方法 LoadPersonThatSpeaksOneOrMoreLanguages 应该返回讲一种或多种所提供语言的所有人员。此方法生成的存储过程似乎不正确:
ALTER PROCEDURE [dbo].[Person_LoadPersonThatSpeaksOneOrMoreLanguages]
(
@languages [dbo].[cf_type_Person_LoadPersonThatSpeaksOneOrMoreLanguages_0] READONLY,
@_orderBy0 [nvarchar] (64) = NULL,
@_orderByDirection0 [bit] = 0
)
AS
SET NOCOUNT ON
DECLARE @_c_languages int; SELECT @_c_languages= COUNT(*) FROM @languages
SELECT DISTINCT [Person].[Person_Id], ...
FROM [Person]
WHERE [Person].[Person_Languages] IN (((SELECT * FROM @languages)))
问题1:我怎样才能达到预期的效果?我应该创建一个 Language 实体并指定 Person 和 Language 之间的 1:n 关联吗?我不喜欢有语言实体。或者我可以指定 Languages 属性必须转换为与表值参数 ( cf_type_Person_LoadPersonThatSpeaksOneOrMoreLanguages_0
) 相同的类型吗?
问题2:生成的PersonCollection
类包含方法LoadPersonThatSpeaksOneOrMoreLanguages
。该方法的参数类型为Language[]
。而不是一个数组,我想要一个IEnumerable<Language>
. 如何在我的 XML 模型中指定它?