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 two tables that I want to search using UNION. The result set has the same columns from both tables. I tried doing a Union using ComposedQueries and ComposeMethod, but I read somewhere on the forum that this does not work with two different tables. I am now trying to do the UNION in a StoredProc and return the results into a projection using ProcedureQuery. But no luck there either :( Any suggestions? Ta - Imtiaz |
|
|
Yes that is correct about the restriction for composed queries where they need to use the same entity type however you should not be running into this making a normal stored procedure call. Can you elaborate on what issue you are having and a quick snippet of code showing how you are making the call?
|
|
|
Hi Jeremy, TableA: int Id string Name string Description .. .. TableB: int Id string Name string Description .. .. class ProjectedResult int Id string Name string Description ProcedureQuery searchQuery = new ProcedureQuery("SP_Search"); searchQuery.Parameters.Add(new ProcedureParameter("Name", name)); searchQuery.Parameters.Add(new ProcedureParameter("Description", description)); List UOW.Find(searchQuery, results); |
|
|
The code doesn't look quite right.. make sure you use a generic list of the Entity type you expect to be returned (in this case ProjectedResult), make sure ProjectedResult is derived from entity and make sure you are assigning the EntityType property of searchQuery to be typeof(ProjectedResult).
|
|
|
Hi Jeremy, That is the very thing - ProjectedResult is a projection. Its not a table, and hence not an Entity. Imtiaz |
|
|
It has to be derived from Entity to be used in this way, you can mark it with the [Transient] attribute if needed to indicate that it should never be persisted if required. If you need to project this into an arbitrary structure then this isn't currently supported Im afraid.
|
|
|
Thanks Jeremy, I wonder why reading results of a SP into a projection is not supported? I have successfully used Projections to read results from a Query, and think it would be a great feature to do the same from a ProcedureQuery. Thanks again for all your prompt help. |
|
|
Our intended approach is that you would create an entity which matches the result set and then that would be the target for the Find call. You will notice the designer will create you a custom entity when the result set doesnt naturally match one of your existing entities to fit with this approach. That said I dont think there is any specific reason why the UnitOfWork.Project calls couldnt work with stored procs, just that this hasn't been a requested feature in the past or something we have thought is required given we like to be fairly entity centric with LightSpeed. If you are keen on us adding this in please pop a new feature request in to the LightSpeed feature forum and then we can look at implementing this once it gets a bit of support :)
|
|