The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

Last post 04-25-2008, 7:21 AM by Mike.Griffin. 16 replies.
Page 1 of 2 (17 items)   1 2 Next >
Sort Posts: Previous Next
  •  03-28-2008, 5:41 AM 8600

    Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    Hi,

    I have an issue with one of my projects and I was wondering if someone could help me out.

    We are doing a join on a number of tables and creating a collection. So

     
    Create a collection of table1 then create a query joining table1 to table2 on a PK and thus adding a new column to our collection.

     
    IF this query does not return a value we have an empty collection.... which is ok... BUT when we add an item to the collection and re-run the query the column is not there in the collection (If I close the form and thus re-create the collection the column is there with the appropriate data) is there anyway to create the join columns even if the join query returns no rows? or would it be best to do a count on the initial query result and then if it is "0" when I add the item destroy and re-create the collection?

     

    Thanks,

     
    Mark



     

  •  03-28-2008, 5:53 AM 8601 in reply to 8600

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    If you don't have to write to the joined object, you could create a view. Then the columns would be generated at code gen time. Otherwise, using count would be a good indicator.

    Regards,

    Scott Schecter
    EntitySpaces | My Site
  •  03-28-2008, 6:18 AM 8602 in reply to 8601

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    Cheers Scott,

    This is on the CF version, so views aren't an option, sorry for not mentioning. Think I will have to do it the other way!

    Mark
     

  •  03-28-2008, 6:46 AM 8603 in reply to 8602

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    Why don't you show us some of the code and point out the issue in more detail (use the code button when posting). My guess is we can point out a way to do it if we have more info.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  04-04-2008, 6:33 AM 8703 in reply to 8603

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    Hi,

    I think this is exactly what the CreateColumnsForBinding() is for, but the only instructions I can find in your API for it say that you should pass a string [] of properties. Could someone shed some light on these please? i.e. what the format for these properties is, how to add multiple columns, columns of different types etc..

     

    Mark

     

  •  04-11-2008, 2:23 AM 8812 in reply to 8703

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    Can anyone shed some light on this for me?

     

    I could really use an example of this, as the API doesnt really give me much help on what the "Properties" or their format are for creating some columns. Also is this the right thing to be using when binding to columns that will not exist until a query join will return data? It seems to be, but i have not been able to get it to work.

     A better way to clarify this is in pseudo code.. (my join is massive and will just look complex here)

     

    Code:
    1    BusinessObjects.tblMyTableCollection Collection1 = new BusinessObjects.tblMyTableCollection();
    2    BusinessObjects.tblMyTable2Collection Collection2 = new BusinessObjects.tblMyTable2Collection();
    3    BusinessObjects.tblMyTableQuery Query1 = new BusinessObjects.tblMyTableQuery();
    5    BusinessObjects.tblMyTable2Query Query2 = new BusinessObjects.tblMyTable2Query();
    6    
    7    Query1.Select(Query1.Field1, Query2.Field2, Query1.Field3);
    8    Query1.InnerJoin(Query2).On(Query1.FK == Query2.PK);
    9    Query1.Where(Query1.Field1 == "abcdef");
    10   Query1.OrderBy(Query1.Field1.Ascending);
    11   
    12   Collection1.load(Query1);
    13   
    14   myList.BindingContext = new BindingContext();
    15   myList.DataSource = Collection1;
    16   myList.Refresh();
    


    If the above code is run, and 0 rows are returned, the joined column "Field2" does not exist in the collection. If I run the query again and return a row.. the "Field2" still doesnt appear to be in the collection and the field in the list is blank.

     HOWEVER... if I exit the form altogether and then come back in and the 1st time the query is run it returns a row, everything works fine.
     

    I just want a way to add the columns so that when I return 0 rows, THEN i return a row all the data will show up

     

    Cheers,

     

    Mark 

  •  04-11-2008, 8:54 AM 8818 in reply to 8812

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    To help us duplicate this, you mentioned CF earlier. Is this a Device Application? What kind of control is myList?


    David Neal Parsons
    www.entityspaces.net
  •  04-15-2008, 6:14 AM 8858 in reply to 8818

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    Did you ever discover what the issue was on this?

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  04-15-2008, 6:45 AM 8859 in reply to 8858

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    Yes this is on the compact framework using SQL server CE, it is a WM5 Smart Device Application. MyList in this instance is a Resco Controlls Advanced List.

    Mike - From what I can see, the issue is that if a collection is created using "BusinessObjects.tblCollection myCollection = new BusinessObjects.tblCollection ()" then populated with a join query with rows returned, the extra columns are added to the collection. If there are no rows returned, the extra columns are not added later, and thus the display can not bind to them. From what I can see, the columns need to be created on the 1st population of the collection or they do not appear.


     

  •  04-15-2008, 8:16 AM 8860 in reply to 8859

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    Okay, now I understand the issue. If the DataTable is already existing when you load an entity or collection the same DataTable is re-used, thus the extra columns fall off by the way side. So, in this case you need to probably not re-use existing collections, which is are preference.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  04-15-2008, 8:49 AM 8861 in reply to 8860

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    Mike,
    Could I not use the method mentioned above ("CreateColumnsForBinding") to create the few extra columns though? Or is there a way or re-creating the datatables/collection?

    Mark

     

  •  04-15-2008, 9:36 AM 8864 in reply to 8861

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    I looked, there is currently no way to do what you are asking. Again, we never really intended for users to "reuse" collections, it's faster to create a new one and use it believe it or not. I will see about adding this for ES2008.  You might try setting the protected "Table" property to null and then call Load, that might work.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  04-16-2008, 1:48 AM 8876 in reply to 8864

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    Mike,

    How do I access the protected property? I can't seem to create a collection within a Private method, so I can't think of a sensible way to create a new collection, without possibly having a large number of them floating around, and then having to load the query onto lots of different collections.

     

    Could I not manually add the columns using

     

    Code:
    EntitySpaces.Interfaces.esColumnMetadata myCol = new EntitySpaces.Interfaces.esColumnMetadata("name", enum, "String");
    
    this.tblDefectCollection1.es.Meta.Columns.Add(myCol);

     If so is that the right format?

    Mark
     

  •  04-16-2008, 4:39 AM 8885 in reply to 8876

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    You would have add a method in your Custom class to gain access to protected methods. Adding columns to our esColumnMetadataCollection is not the same as the underlying ADO.NET columns collection.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  04-16-2008, 6:29 AM 8890 in reply to 8885

    Re: Joining in a query where no rows are returned.. is it possible to return all the columns into the collection?

    mike, I can't seem to find the "Table" property anywhere when doing an override.

     

    Mark 

Page 1 of 2 (17 items)   1 2 Next >
View as RSS news feed in XML