StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      


««12

Turning off default PK Clustered indexExpand / Collapse
Author
Message
Posted 07/16/2007 4:09:57 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 09/26/2008 8:30:36 AM
Posts: 2,685, Visits: 1,886
Yep, Paul is right... Just override the OnSetDefaultValues() method and set your PK in there by calling whatever method you create to get the sequential guid from the date. 

Dim LoPkField As Reflection.PropertyInfo = Me.GetType.GetProperty(Me.PrimaryKeyField)

There is a faster way to do that, Paul

Imports MicroFour.StrataFrame.Business

...

Protected Overrides Sub OnSetDefaultValues()
    MyBase.OnSetDefaultValues()

    '-- Set Value for GUID PK
    '-- Get a reference to the property descriptor (which doesn't use reflection)
    Dim desc As FieldPropertyDescriptor = Me.GetPropertyDescriptor(Me.PrimaryKeyField)

    '-- If the PK is a Guid Generate a Sequential GUID to prevent Index fragmentation
    If desc.PropertyType Is GetType(Guid) Then
        desc.SetValue(Me, Common.NewSeqID())
    End If
End Sub

This way uses the FieldPropertyDescriptors created in the partial class... which are much faster than using reflection   Obviously, you're way will work, but the slowness of reflection was the exact reason that we created those descriptors.


www.bungie.net
Post #10321
Posted 07/16/2007 6:02:26 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 7:42:15 AM
Posts: 359, Visits: 2,323
Awesome Ben I knew the property descriptor was there but didn't think to use it!

Thanks

Post #10329
Posted 07/18/2007 8:20:55 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 3:14:25 PM
Posts: 148, Visits: 2,718
You guys are terrific. I'm really glad I asked about this. Clustered indexes here I come
Post #10439
« Prev Topic | Next Topic »

««12

Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 4:07pm

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.063. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.