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 cannot find any reference how I access a field of a joined table when I use a query object with a join property set. thanks gmd |
|
|
Are you using LINQ for your querying? If so you can just select out the required properties as part of the projection (.Select call). e.g.
If not, you have two options. If you want to select out a whole entity and then access its properties afterwards you should use UnitOfWork.FindGroup, e.g.
And then enumerate results which will be Tuples of EntityA,EntityB. Or if you want to select out selected fields into an arbitrary result you should use UnitOfWork.Project - have a read through http://www.mindscapehq.com/documentation/lightspeed/Advanced-Querying-Techniques/Exploring-the-Query-Object for information about working with projections.
|
|
|
thanks Jeremy, that helped .. have to get my head around a few things at the moment :) .. I use query objects, because that's the way I understood how to create queries in a generic form when I have all type and field information in a string format, read from definitions and only checked at run time and not at compile time .. regards gmd |
|
|
still have a question: I have types and fieldnames etc only as strings .. I am programming on a meta level so I cannot use EntityTuple I use Type myNClassType = Type.GetType("Dashboard." + ntableName); Type myAkClassType = Type.GetType("Dashboard." + aktableName); Query query = new Query();
I had to change EntityTuple constructor fro internal to public to do that I works and I get results but I still do not know how to access a field of either entity a or b using a statement like below aEntity.GetType().GetProperty("Name").GetValue(aEntity, null)) as I said before . I do not have any types or tablenames or fieldnames at compile time .. they are all strings at compile time and only become types at runtime .. sorry to be a pain ... regards gmd |
|
|
Would this cover what you are after?
|
|
|
I will give it a try .. it looks like it could work for me. thanks gmd |
|
|
I tried it and it works, but I have another question regarding the outer join I do this
Type[] typeArray = { EntityClassType, NEntityClassType };
var results = new EntityTuple(typeArray);
var query = new Query();
query.Join = Join.Outer(typeArray[0], typeArray[1], foreignKeyFieldName, linkedFieldName);
query.EntityType = EntityClassType;
query.QueryExpression = Entity.Attribute(selectedFieldName).In(querySet); and it works fine and you do this try { var id = typeModel.TypeModel.IdFieldModel.GetValueFromReader(values); return id; } catch (InvalidCastException) { return null; } When the right entity (from the joined table) is null you get an InvalidCastException. Why do you use an exception for this situation and not just fix it with testing for null or "" (empty string) first ? You test for null but not for "" this will fix it in the two relevant places public static object FirstToInt64(object[] values) { object value = values[0] ;
I prefer not to get exceptions for expected situations ? thanks gmd |
|