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
|
I have a situation where it would be nice to be able to populate an entity where the columns may or may not be present in the underlying view or procedure. From what I can tell, this is not possible. Is there any way to make it happen or maybe dynamically build an entity type on the fly? I am using this for some reporting where I have some generic code that executes a view as defined in my database. Depending on which view is executed, some columns may or may not be present for any given view. Instead of getting the error that I am unable to materialize the view, it would be nice to be able to somehow indicate if the field is not present that it defaults to null or something. Thanks! |
|
|
Hi roncalw, You cannot "dynamically" build an entity type on the fly, but have a look at using the NamedAggregates feature to cater for the situation you have described above. NamedAggregates is a feature within LightSpeed which allows you to define fields which are only loaded when you specify an associated aggregate name. e.g. You might have a binary field named Photo which you only want to load for certain situations. To match up with your reporting example above, you could have a named aggregate specified on all of the fields which are conditionally loaded, and then have a named aggregate per load strategy and the columns which are not part of that strategy will not be present on the loaded entities. e.g. With the above example, you might call your named aggregate "WithPhoto", and then when building up your query you would specify query.Aggregate = "WithPhoto", or if you are using LINQ you can use the WithAggregate extension method. Does that sound like what you are after?
Jeremy
|
|