在过去的几天里,我一直在旋转我的轮子,无法确定我做错了什么。我正在尝试设置一个可以在 esql 中调用的 TVF。我开始使用它作为我的指南,根据需要将详细信息更新到 6.1.1。我所有的努力都收到“无法解析为有效的类型或函数”。我能够在 Database.SqlQuery 结果中获得结果,但不能在 ESQL 或 Linq 中获得结果。
有人可以看看这个并给我一个线索吗?我会很感激。
这是我所拥有的:
[T-Sql]
CREATE FUNCTION [Reconciliation].[GetAccountUnits]
( @PerspectiveId INT
, @EffectiveDate DATETIME
)
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN
(
SELECT [AccountId] = V.[AccountId]
, [PerspectiveId] = V.[PerspectiveId]
, [Units] = V.[Units]
...
)
[存储模型]
<Function Name="GetAccountUnits" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="true" ParameterTypeSemantics="AllowImplicitConversion" Schema="Reconciliation">
<Parameter Name="PerspectiveId" Type="int" Mode="In" />
<Parameter Name="EffectiveDate" Type="datetime" Mode="In" />
<ReturnType>
<CollectionType>
<RowType>
<Property Name="AccountId" Type="int" Nullable="false" />
<Property Name="PerspectiveId" Type="int" Nullable="false" />
<Property Name="Units" Type="decimal" Precision="28" Scale="15" Nullable="false" />
</RowType>
</CollectionType>
</ReturnType>
</Function>
[概念模型]
<EntityContainer>
....
<FunctionImport Name="GetAccountUnits" IsComposable="true" ReturnType="Collection(MBSA.CARS.Domain.Reconciliation.GetAccountUnits)">
<Parameter Name="PerspectiveId" Mode="In" Type="Int32" />
<Parameter Name="EffectiveDate" Mode="In" Type="DateTime" />
</FunctionImport>
</EntityContainer>
<ComplexType Name="GetAccountUnits">
<Property Type="Int32" Name="AccountId" Nullable="false" />
<Property Type="Int32" Name="PerspectiveId" Nullable="false" />
<Property Type="Decimal" Name="Units" Nullable="false" Precision="28" Scale="15" />
</ComplexType>
[映射]
<FunctionImportMapping FunctionImportName="GetAccountUnits" FunctionName="MBSA.CARS.Domain.Reconciliation.Store.GetAccountUnits" >
<ResultMapping>
<ComplexTypeMapping TypeName="MBSA.CARS.Domain.Reconciliation.GetAccountUnits">
<ScalarProperty Name="AccountId" ColumnName="AccountId" />
<ScalarProperty Name="PerspectiveId" ColumnName="PerspectiveId" />
<ScalarProperty Name="Units" ColumnName="Units" />
</ComplexTypeMapping>
</ResultMapping>
</FunctionImportMapping>
[函数存根]
public partial class ReconciliationContext : DomainContext
{
...
[DbFunction("MBSA.CARS.Domain.Reconciliation.Store", "GetAccountUnits")]
public virtual IQueryable<GetAccountUnits> GetAccountUnits(int perspectiveId, System.DateTime effectiveDate)
{
var perspectiveIdParameter = new ObjectParameter("PerspectiveId", perspectiveId);
var effectiveDateParameter = new ObjectParameter("EffectiveDate", effectiveDate);
return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<GetAccountUnits>("[ReconciliationContext].[GetAccountUnits](@PerspectiveId, @EffectiveDate)", perspectiveIdParameter, effectiveDateParameter);
}
}
我已经尝试了所有这些:
[ESQL]
select value it from MBSA.CARS.Domain.Reconciliation.Store.GetDecimalProperty(1, DATETIME'2006-05-31 00:00') As it
select value it from Reconciliation.Store.GetDecimalProperty(1, DATETIME'2006-05-31 00:00') As it
select value it from Reconciliation.GetDecimalProperty(1, DATETIME'2006-05-31 00:00') As it
select value it from ReconciliationContext.GetDecimalProperty(1, DATETIME'2006-05-31 00:00') As it
select value it from GetDecimalProperty(1, DATETIME'2006-05-31 00:00') As it
GetDecimalProperty(1, DATETIME'2006-05-31 00:00')