0

在过去的几天里,我一直在旋转我的轮子,无法确定我做错了什么。我正在尝试设置一个可以在 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')
4

1 回答 1

0

在深入研究程序集后,我发现 ssdl、csdl 和 msl 嵌入式资源已过时。进一步的调查显示,生成视图的后期构建命令在源代码控制中丢失了。我在重建项目中添加了几次,现在一切正常。

于 2014-12-17T22:35:58.300 回答