This project has moved. For the latest updates, please go here.

LoadContext constructor without a key?

Apr 22, 2011 at 5:17 PM

Right now I have a ViewModel that loads some static non-user related data that doesn't require any id or key of anysorts, so I'm hardcoding a static string as the object key for that viewmodel. I find it a little offputting having a string that is nowhere used and not needed, so I'm asking if it would make sense to enable LoadContext without keys? A derived type perhaps?

Coordinator
Apr 22, 2011 at 8:05 PM

Hi -

It needs to have an identity of some sort, but it's up to you what it is.  Typically you would use a const string from some where but if you could use a derived type name:

 

public class MyLoadContext : LoadContext {

	public MyLoadContext() : base(GetType().FullName) {

	}

}

 

I do get what you're saying, but basically AgFx is designed for view models that are going to have many instances.  Using a constant identity allows static things to fit into this model - if you look at LoginModel and LoginLoadContext they do exactly this.

Thanks,

Shawn