error when query views

Dec 21, 2010 at 11:00 AM

Hi There,

i want to query a view, but my view has no default constructor ist that possible?

  [DataContract]
    public class MensaViewModel2 : ViewModelIRapidView
    {
        public MensaViewModel2(INavigationService navigationService)
            : base(navigationService)
        {
            this.IsBeingActivated();

        }

        [DataMember]
        public string Name { getset; }

        [DataMember]
        public Guid Id { getset; }

        [DataMember]
        public bool IsFavorite { getset; }

        public override void IsBeingActivated()
        {
            
        }
    }
RapidRepository<MensaModel>
                .AddView<MensaViewModel2>(x => new MensaViewModel2(navigationService)
                {
                    Name = x.Name
                });

my query
 var mensenViewModels = mensaRepository.Query<MensaViewModel2>().ToList();
I get an MissingMethodException.

Any ideas how to get that working without default constructor?

Best regards
Dima
Coordinator
Dec 21, 2010 at 11:38 AM
Edited Dec 21, 2010 at 11:39 AM

Hi Dima,

This won't work at the moment, it has to do with how I'm deserialising the views and entities, only the default constructor is used.

I been asked by a few people for changes to the serialisation and deserialsation so I can add this to the list for the next release.

I'm putting new releases out fairly quickly so it shouldnt be too long after christmas when the next version is ready.

Work Around

This might not suit but something like the following might work?

 

[DataContract]
public class MensaViewModel2 : ViewModel, IRapidView
{
    [DataMember]
    public string Name { get; set; }

    [DataMember]
    public Guid Id { get; set; }

    [DataMember]
    public bool IsFavorite { get; set; }

    public INavigationService MyNavigationService
    {
        set
        {
            this.NavigationService = value;
            this.IsBeingActivated();
        }
    }

    public override void IsBeingActivated()
    {

    }
}

 

 

public MainPage()
{
    InitializeComponent();

    INavigationService navigationService = new NavigationService();

    RapidRepository<MensaModel>
                .AddView<MensaViewModel2>(x => new MensaViewModel2
                {
                    Name = x.Name,
                    MyNavigationService = navigationService
                });
}

 

I realise this is not a great solution but might help for the time being.

Kind Regards,

Sean.