This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, i have a problem whit the eager load collection. i've an entity called Ensayo and it have a collection of EnsayoParametro. i want to modify the items from the Collection so that i set the eager load collection in true, but when i try to get all the Ensayos to show them in a table, i call to the method getAll() and it throw an exception that i can`t understand.
here is the code of the method getAll() public IList<Ensayo> getAll()
and that is the stack trace of the exception in throws: at Mindscape.LightSpeed.Model.TypeModel.(LightSpeedContext , IDataReader ) |
|
|
i forgot to tell that the exception is: Object reference not set to an instance of an object. |
|
|
Hi Arielsz |
|
|
Hi Arielsz, Please reply to this post not the previous one. Johan |
|
|
Hi Arielsz, In 2.1 you would get this exception if an entity type (e.g. EnsayoParametro) didn't have a public default constructor. We fixed this in 2.2 to give a more meaningful exception. Can you check which version of LightSpeed you are on, and upgrade to 2.2 if necessary and see if it helps identify the problem? Thanks! |
|
|
no, there is no inner exception. Thanks |
|
|
thanks. that was the error. i added a public default constructor and it's ok now. i've another problem, i want to modify the items from the collectio so i use the addrange method but it throws an exception because it is a readonly property. how can i do to modify the collection of EnsayoParametros?
thanks
ariel |
|
|
You can create your own derived collection type: public class EnsayoParametroCollection : EntityCollection<EnsayoParametro> { ... } and declare the _ensayoParametros field and EnsayoParametros property as this type rather than as EntityCollection<EnsayoParametro>. Note that the designer does not directly support custom collection types. Alternatively if you are targeting .NET 3.5 you can create extension methods on EntityCollection<T>. This has the advantage of working with designer-generated models. However you should not need to do this in order to use AddRange: EntityCollection<T> defines an AddRange method so you should just be able to call that. Or am I misunderstanding? If I've misunderstood then could you post a code snippet showing what you are wanting to do? |
|