Multiple Tables in an object


Author
Message
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Is there a command to create the tables in SQL Server from the XSD schema ?

Not that I'm aware of... I wouldn't suspect that it would be in SQL Server Management Studio, but it certainly wouldn't surprise me if there was a 3rd party tool that would do it. 

I downloaded the sample and see to BOs, but I of course have nothing to map them to in sql server.

Hrm... the StrataFrameSample database with sample data should be deployed by the SF install to the same server that the StrataFrame database was installed.  So, unless you skipped that option, you should have some sample data somewhere.

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Smile uh, no I have the SF sample database installed.

My point was the data schema Robert send was for two tables that aren't part of the sample data

And I was wondering if before creating the sample you had somehow magically imported from the schema into a DB so you could map with the BO mapper.

I think I was having a bad expressing myself day BigGrin

( but it did get me Googling and it turns out there is indeed a way to create XSD Schemas from SQL 2005 with t_sql and then the there a way of creating data structures in SQL from schemas, but the format Robert used wasn't the one, so I guess that wasn't the intention )

Just trying to catch up on the huge gaps in my basic knowledge of VS/VB tricks w00t

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Ah, I gotcha... the XSD that Robert posted is not part of the StrataFrameSample database... it was something else that he was working on (or maybe he modified his sample database, I dunno).  So, it's starting to make sense why you thought that the XSD he posted was part of the SF sample. 

I'm glad you found a few tools to convert the XSDs and so forth.  But just remember, the only 2 sources of structures for the BOMapper are the DDT and the database itself on the server.

Michael Cobb
Michael Cobb
StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
Charles:  The way I did this was to add a State table to the SF Sample database.  The table consists of StateName and StateCode columns.  StateName has the long names and StateCode has the abbreviations.  Then I went into the VB.NET CRMApplication sample.  I added a BO called StateBO to that project and used the BusinessObjectMapper to create the partial class for it. 

I added the following custom code to the StateBO for a parameterless data retrieval method:

''' <summary>

''' Fills the business object with all records order by primary key

''' </summary>

''' <remarks></remarks>

Public Sub FillAllStateTable()

'-- Establish local

Dim loCommand As New SqlCommand()

'-- Create the command

loCommand.CommandText = "SELECT * FROM State ORDER BY StateCode"

'-- Execute the command

Me.FillDataTable(loCommand)

End Sub

#End Region

Then I modified the custom code for the CustomersBO by adding the following lines of code only:

Private WithEvents _State As New StateBO()

''' <summary>

''' This method handles the Navigated event of the Customers business object to allow

''' you to set the filter on the State business object.

'''

''' You can filter the StateBO to only show records that match the current record

''' within the CustomersBO.

''' </summary>

''' <param name="e"></param>

Private Sub CustomersBO_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles Me.Navigated

'-- Set the filter on the internal StateBO

' (Only necessary if the CompanyBO will contain more than one record)

Me._State.Filter = "StateCode = '" & CType(Me.CurrentRow("cust_State"), String) & "'"

End Sub

Next I did a BuildAll so that the Company and State Business Objects were recompiled.

To test it, I moved the State Textbox (Textbox9) to the bottom of the form (you could just as easily remove it) and replaced it with a StrataFrame ComboBox on which I set the following properties: BusinessObject=Customers, BindingField = cust_State, DropDownStyle=DropDownList, PopulationType=BusinessObject, PopulationDataSourceSettings=StateBO.FillAllStateTable().  The PopulationDataSourceSettings property gets built by clicking the ellipsis on the property.  Inside there I put {0} under Display Member and Drop-Down Display, StateName under ValueMember and added StateCode to DisplayMember.

When you run the form the combo box will display the state code for the current record as you browse.  If you edit/add a record the combo box displays a list of all possible state codes.  If you change a value and save it, the Customers table will save the state name associated with the state code.

That should get you started if you're still looking at this.

Michael Cobb
Michael Cobb
StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
Ben,

In the following declaration statement what is the naming convention calling for the variable name to begin with an underline?  Is this typically used for property variables?

Private WithEvents _State As New StateBO()


Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Thanks Ben - I knew it wasn't part of the Strataframe Sample Data but it was referenced in the zip you posted so I thought you might have used his XSD to add the tables to the sample data in some way everyone but me knew about "Smile
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)Advanced StrataFrame User (952 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Thanks a lot for this Robert. I'll file it away for when my SF level rises BigGrin
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The underscore is just a convention that we use internally.  It's not a .NET naming convention.  However, with VB, when you create a "Public WithEvents MyField As SomeType" field on your class, VS behind the scenes creates a field named the same as your field, but with an underscore (_MyField) and instead of creating a public field, it wraps the implicit private (_MyField) with a public property. 

Other than that, I don't know of any convention that says that your private fields (or any other member fields) need to start with an _.  We just do because we like the convention.  I've looked through the .NET framework using Reflector a few times, and in most of their stuff, they either start their private fields with an _ and camel case them or just camel case them (_myField or myField).  It's entirely up to you.

I can't find the MSDN page that lists the .NET naming conventions, but this guy has most of them listed.  Look down at the one that says "Class-Level Private and Protected Variables"

http://www.irritatedvowel.com/Programming/Standards.aspx

Michael Cobb
Michael Cobb
StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
Thanks Ben.  I hadn't seen the underscore naming convention except for in the StrataFrame code but I like it and think I will use it as well.
choyt
choyt
StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)
Group: Forum Members
Posts: 78, Visits: 246
Hi Folks

I have this working with one caveat.

I have a "Users" table that hold basic inforamtion such as First and Last name but am using forms authentication and want to take full advantage of that so am using the aspnet_ tables as well. To do this, I am joining together my Users table with aspnet_Users and aspnet_Membership. There is no data of use to me in the aspnet_Users table but there is quite a bit of useful info in the membership table.

To do this the way that has been described, I am customizing the UserName field in my user table (the FK to the UserName field in aspnet_Users) and replacing it with a BO that I mapped against aspnet_membership. I would much rather keep my user name field intact but there is no way in the object mapper to create a field. You can only use (override) fields that are aleady part of the underlying database table.

I can see these work arounds

  1. Create a "fake" field in the database to fool the mapper into believing there is an extra field.
  2. Manually modify the designer.vb file each time I do a build (kind of pain but not out of the question)
  3. Overwriting my UserName field.

Is there something simple and basic I'm missing or is my understanding correct?

Thanks! BigGrin

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