none
ADO.NET 1.5ctp2 RRS feed

  • Pergunta

  • Olá Pessoal,
    Estou com problemas, comecei a utilizar o ADO.NET Data Services 1.5 CTP2 - Entity Framework, no VS 2008 com Silverlight 3.. Mais ao utilizar o principal beneficio "Query Projections" não executa dentro do silvrlight.

    O serviço esta certinho, consigo buscar as informações direto no browser, executar algo como:
    http://localhost:1466/Conference.svc/ConferenceCurrent(107)?$select=Status
    http://localhost:1466/Conference.svc/ConferenceCurrent/$count

    Ou seja, esta tudo ok com as configurações do ADO 1.5CTP2. retornando.. O erro ao tentar executar com o silverlight esta abaixo: Mais abaixo segue como estou executando no silverlight.

    Referência:
    http://msdn.microsoft.com/en-us/library/ee473425(VS.100).aspx
    http://blogs.msdn.com/astoriateam/archive/2009/09/01/ado-net-data-services-v1-5-ctp2-projections-overview-server.aspx
    http://blogs.msdn.com/astoriateam/archive/2009/09/17/introduction-to-data-binding-in-silverlight-3-with-ctp2.aspx


    ======================================
    MethodAccessException was unhandled by user code
    =====================================

    System.Linq.Expressions.Expression.Lambda(System.Linq.Expressions.Expression,
    System.Collections.Generic.IEnumerable`1<System.Linq.Expressions.ParameterExpression>)
    =============================================================

    System.MethodAccessException was unhandled by user code
      Message="System.Linq.Expressions.Expression.Lambda(System.Linq.Expressions.Expression, System.Collections.Generic.IEnumerable`1<System.Linq.Expressions.ParameterExpression>)"
      StackTrace:
           at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags)
           at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
           at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
           at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
           at System.Linq.Expressions.Expression.Lambda(Type delegateType, Expression body, IEnumerable`1 parameters)
           at System.Linq.Expressions.Expression.Lambda(Type delegateType, Expression body, ParameterExpression[] parameters)
           at System.Linq.Expressions.Expression.Lambda(Expression body, ParameterExpression[] parameters)
           at System.Data.Services.Client.ProjectionPlanCompiler.RebindEntityMemberInit(MemberInitExpression init)
           at System.Data.Services.Client.ProjectionPlanCompiler.VisitMemberInit(MemberInitExpression init)
           at System.Data.Services.Client.ExpressionVisitor.Visit(Expression exp)
           at System.Data.Services.Client.ProjectionPlanCompiler.VisitLambda(LambdaExpression lambda)
           at System.Data.Services.Client.ExpressionVisitor.Visit(Expression exp)
           at System.Data.Services.Client.ProjectionPlanCompiler.CompilePlan(LambdaExpression projection, Dictionary`2 normalizerRewrites)
           at System.Data.Services.Client.AtomMaterializer.CreatePlan(QueryComponents queryComponents)
           at System.Data.Services.Client.AtomMaterializer..ctor(AtomParser parser, DataServiceContext context, Type expectedType, Boolean ignoreMissingProperties, MergeOption mergeOption, AtomMaterializerLog log, Action`2 materializedObjectCallback, QueryComponents queryComponents, ProjectionPlan plan)
           at System.Data.Services.Client.MaterializeAtom..ctor(DataServiceContext context, XmlReader reader, QueryComponents queryComponents, ProjectionPlan plan, MergeOption mergeOption)
           at System.Data.Services.Client.DataServiceRequest.Materialize(DataServiceContext context, QueryComponents queryComponents, ProjectionPlan plan, String contentType, Stream response)
           at System.Data.Services.Client.QueryResult.ProcessResult[TElement](DataServiceContext context, ProjectionPlan plan)
           at System.Data.Services.Client.DataServiceRequest.EndExecute[TElement](Object source, DataServiceContext context, IAsyncResult asyncResult)
           at System.Data.Services.Client.DataServiceQuery`1.EndExecute(IAsyncResult asyncResult)
           at Onofre.Return.Silverlight.Controls.DragDockPanel.<>c__DisplayClass94.<OnConferenceNoteFindQueryComplete>b__93()
      InnerException:
    =======================================================================

    ESTOU EXECUTANDO NO SILVERLIGHT ASSIM:

    private void btnFindInvoiceNote_Click(object sender, RoutedEventArgs e)
    {
     queryConferenceNoteFind = (from cn in contextConference.ConferenceCurrent
                        select new ConferenceCurrents
                             { Status = cn.Status}) as DataServiceQuery<ConferenceCurrents>;

    // Aqui montado a query certinha...
    // O retorno de queryConferenceNoteFind :
    // http://localhost:1466/Conference.svc/ConferenceCurrent()?$select=Status
    // Isto executado direto no browser retornado numa boa os valores usando Projections do ADO.Net 1.5ctp2

    queryConferenceNoteFind.BeginExecute(OnConferenceQueryComplete, queryConferenceNoteFind);

     }

    private void OnConferenceQueryComplete(IAsyncResult asyncResult)
    {
         Dispatcher.BeginInvoke(() =>
            {
                  var query = asyncResult.AsyncState as DataServiceQuery<ConferenceCurrents>;
                  try
                  {

                     IEnumerable<ConferenceCurrents> returnedConferenceNoteFind = query.EndExecute(asyncResultNoteFindQueryComplete); // O erro acontece nesta linhanesta linha


                    if (returnedConferenceNoteFind != null)
                      {
                        ....
                      }
                   else
                     {
                        MessageBox.Show("....");
                     }
                  }
                catch (DataServiceQueryException ex)
                    {
                       txtCurrentInvoiceNote.Text =
    string.Format("Erro: {0} - {1}",
                            ex.Response.StatusCode.ToString(), ex.Response.Error.Message);
                     }
               
             });

    }

    sexta-feira, 27 de novembro de 2009 16:20

Respostas