0

Я пару дней назад вращал свои колеса, и не могу определить, что я делаю неправильно. Я пытаюсь настроить TVF, который я могу вызвать в esql. Я начал использовать this в качестве моего руководства, обновляя детали до 6.1.1 по мере необходимости. Все мои усилия получают «не могут быть разрешены в действительный тип или функцию». Я могу получить результаты в результате Database.SqlQuery, но не в ESQL или Linq.Невозможно разрешить функцию, отмеченную таблицей, в EF6.1 Entity SQL

Может ли кто-нибудь взглянуть на это и дать мне ключ? Буду премного благодарен.

Вот что у меня есть:

[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] 
... 
) 

[StorageModels]

<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> 

[ConceptualModels]

<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') 

ответ

0

После копания в сборку я обнаружил SSDL, CSDL , а встроенные ресурсы msl устарели. Дальнейшее исследование показало, что команда post build для сгенерированных представлений была потеряна в контроле источника где-то вдоль линии. Я добавил их обратно в восстановленный проект пару раз, и теперь все работает нормально.

Смежные вопросы