Instead of a view - Is this possible or nonsense


Author
Message
Thomas Holste
Thomas Holste
StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi there,

I wonder if something like this would work. I got a BO which maps one table and send a

SQL-command like this



select table1.field1, table1.field2*table1 as somecalcfield, table2.anotherfield from table one left outer join table2 on.......



I know, that I could easily get this by using a view and map it but for reasons of runtime-flexibility I would like to know if this field from table2 can be accessed through the BO which maps only table1. It would make some situations easy where I want to replace foxpro-code utilizing the create cursor-command.

Thanks in Advance

Thomas






Trent Taylor
Trent Taylor
StrataFrame Developer (9.8K reputation)StrataFrame Developer (9.8K reputation)StrataFrame Developer (9.8K reputation)StrataFrame Developer (9.8K reputation)StrataFrame Developer (9.8K reputation)StrataFrame Developer (9.8K reputation)StrataFrame Developer (9.8K reputation)StrataFrame Developer (9.8K reputation)StrataFrame Developer (9.8K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Thomas:

You can most definitely access it and you can even create a custom property so that it is strong-typed in code, etc.  But you will not be able to write back to the table without code changes.  If you need the table to be updatable, then you will have to use a view.  If you are just bringing it in for client-side access, then you are good to go.
Thomas Holste
Thomas Holste
StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi Trent,




thank you for your answer but how do I implenet accessing the field from the joined table. The query is already working but I do not see the field from table2.  I implemented a custom property but do not know how to fill ist with data?



<Browsable(False), _

BusinessFieldDisplayInEditor(), _

Description("Warengruppen-Bezeichnung"), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public ReadOnly Property [FIELDFROMTABLE2]() As System.String

Get

Return ?????

End Get

End Property



I do not know what to write in that return command?

Thanks a lot

Thomas






StrataFrame Team
S
StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You would just copy one of the fields from the designer file on the business object like so:

Public Property FieldFromTable2 As String
   Get
      Return DirectCast(Me.CurrentRow("FieldFromTable2"), String)
   End Get
   Set (value As String)
      Me.CurrentRow("FieldFromTable2") = value
   End Set
End Property

Whatever you put as the "FieldFromTable2" when accessing the CurrentRow indexer just needs to match the alias of the column in the results of the query.
Thomas Holste
Thomas Holste
StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi Ben,

thanks a lot for your help. Your example has taught me a fine way to to something similar to the Cursors I used a lot for statistics and reporting. I can now build a BO consisting of Data from different tables, enpty fields to fill later and calculated fields in one select-command. There is one assumption/question left: As I understand it, I can add data to the BO temporarily (not wanting to save anything) for the above mentioned reasons as Long as I do not issue a save-command and undo this in my form-closing-Event? I tried it and it seems to work but I am still a bit insecure.

Best regards

Thomas



StrataFrame Team
S
StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)StrataFrame Developer (4.1K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Nothing to be insecure about, Thomas Smile  The BOs are used to save records as well as act as a client-side storage for data.  Since they have a DataTable that stores the data internally, they can have any structure you want.  

Also, you can add columns to the DataTables and still save BOs.  A business object has a list of the mapped columns from the table in the database, so when it saves, it will only try to save back the columns that are mapped and it will ignore the others.
Thomas Holste
Thomas Holste
StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)StrataFrame User (356 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi Ben,

thanks again for your help,

Best regards

Thomas
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search