Seting Default Values


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
Yes, the constructor for the BrokenRule class is internal (Friend in VB), to prevent broken rules from being added outside of the business objects themselves.  If you want to be able to add a broken rule from outside of a business object, then you'll need to create a public method that will turn around and call the BusinessLayer.AddBrokenRule method internally.
Bradley Marston
Bradley Marston
StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)
Group: Forum Members
Posts: 24, Visits: 119
For one last question on the subject , how do I add a broken rule to a created business object. for example

BOCustomers.BrokenRules.Add()  takes a parameter of type MicroFour.StrataFrame.Business.BrokenRule 

When I try to create an object of MicroFour.StrataFrame.Business.BrokenRule I cannot use the new keyword, and all the relevent properties seem to be Read Only.


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
Yes, there is an overload to accept the field name as a string.  The overload to accept the parameter as an enum (which is defined within the partial class of the business object) just .ToString()s the enum value and calls the other overload.  So, you can certainly make it dynamic, and also add broken rules for custom properties that do not have a value in the enum.
Bradley Marston
Bradley Marston
StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)
Group: Forum Members
Posts: 24, Visits: 119
On a related note is there a way to similarly add BrokenRules without having to hardcode the first parameter and make

it dynamic?

Me.AddBrokenRule(MyBusinessObjectFieldNames.cust_lname, "Last name must be at least two characters.")

becomes

dim myvalue as string = "cust_lname"

Me.AddBrokenRule(myvalue , "Last name must be at least two characters.")


 


 

Bradley Marston
Bradley Marston
StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)
Group: Forum Members
Posts: 24, Visits: 119
After I posted the question I thought there would be a way to do it using current row, but did not have the time to investigate it. Your reponse is very much apprecited and will save me a lot of time.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yeah...as you already know, macros were a very dangerous thing since it was not strong-typed, but also a useful tool when you just want to "strong-arm" something.  In .NET, you will use reflection.  However, in this example you can just use the CurrentRow exposed on the BO.

Dim loRow As DataRow

For Each loRow IN MyTempDataTable.Rows
    MyBO.CurrentRow.Item(loRow.Item("FieldName")) = loRow.Item("FieldValue")
Next


Bradley Marston
Bradley Marston
StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)
Group: Forum Members
Posts: 24, Visits: 119
I have a BO with a lot of fields that need to set with defaults, I also have a datatable with the field name and value. Is there a way to set these defaults looping thru the data table without having to use a select case where i must type Case datatable.fieldname = me.fieldname. For example in vfp one could use macro

substitution , but not in vb.net or c sharp.net

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