Welcome Guest Search | Active Topics | Members | Log In | Register

sql server default values and field order Options · View
edu
Posted: Friday, February 12, 2010 11:41:42 AM
Rank: Newbie
Groups: Member

Joined: 10/5/2009
Posts: 7
Points: 21
Location: Derio
hello all


I have just generated classes and hbm files using nconstruct lite from my sql server database.

Nconstruct did a good work for me, but i have found two issues

1. Seems nconstruct ignores the default values declared in database columns.
2. nconstruct generates fields in alphabetical order, not in the order they have been created in the database.

of course, you can make these changes manually, but this is not a good solution for me.
my database model has about 1200 fields distributed in 60 tables and views.


May be it should be easy to implement these two improvements for the next version !


Thanks
sebastijan
Posted: Monday, February 15, 2010 6:31:51 PM
Rank: Advanced Member
Groups: Member

Joined: 8/29/2007
Posts: 67
Points: 201
Location: NConstruct Support Team
Hi,

1.
We are using the OleDbConnection provider object and the following meta-data can be read from it:

{ColumnName}
{ColumnOrdinal}
{ColumnSize}
{NumericPrecision}
{NumericScale}
{DataType}
{ProviderType}
{IsLong}
{AllowDBNull}
{IsReadOnly}
{IsRowVersion}
{IsUnique}
{IsKey}
{IsAutoIncrement}
{BaseSchemaName}
{BaseCatalogName}
{BaseTableName}
{BaseColumnName}

There is no default value that can be retrieved. If you are aware of any libray that gets the default values we can evaluate it and try to use it.

2. Regarding the properties sort order: We created the options dialog that you can use to apply the sort you want. It is also possible to set the logging for the NConstruct Builder application if needed. See figures below.







The new NConstruct version 2.5.1 will be available tomorrow.

Regards,
Pistotnik S.
_______________________

NConstruct Support Team
support@nconstruct.com
http://www.nconstruct.com
_______________________
sebastijan
Posted: Monday, February 15, 2010 10:24:21 PM
Rank: Advanced Member
Groups: Member

Joined: 8/29/2007
Posts: 67
Points: 201
Location: NConstruct Support Team

Hi Edu,

The new NConstruct Lite version 2.5.1 is already available for download and you can get it from the following URL:

http://www.nconstruct.com/Productfiles/NcbSetupLite.msi

Regards,
Pistotnik Sebastijan
_______________________

NConstruct Support Team
support@nconstruct.com
http://www.nconstruct.com
_______________________
edu
Posted: Tuesday, February 16, 2010 5:02:00 PM
Rank: Newbie
Groups: Member

Joined: 10/5/2009
Posts: 7
Points: 21
Location: Derio
Thanks a lot for your improvement !

it will be very usefull to me.

...

For getting default values, maybe this code helps you (sorry it's vb.net) :


Imports System.Data.OleDb

Namespace utils
Public Module Module1

Function get_defaults_for_table(ByVal connection_string As String, ByVal table_name As String) As String

Dim mySqlConnection As OleDbConnection
Dim s As String = ""

Dim restrictions As String() = New String(3) {Nothing, Nothing, table_name, Nothing}
mySqlConnection = New OleDbConnection(connection_string)
mySqlConnection.Open()

'Dim o As System.Data.DataTable = mySqlConnection.GetSchema("Columns", restrictions) 'also works
Dim o As System.Data.DataTable = mySqlConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, restrictions)
Dim c As System.Data.DataRow

For Each c In o.Rows
If c.Item("COLUMN_HASDEFAULT") = True Then
s = s & (c.Item("COLUMN_NAME") + " default value is " + c.Item("COLUMN_DEFAULT").ToString) + "/"
End If
Next

mySqlConnection.Close()

Return s
End Function

End Module
End Namespace


Making this call

Console.WriteLine(Module1.get_defaults_for_table("Provider=sqloledb;Data Source=SD200001;Initial Catalog=Northwind;Integrated Security=SSPI;", "Products"))


i got this

UnitPrice default value is ((0))/UnitsInStock default value is ((0))/UnitsOnOrder default value is ((0))/ReorderLevel default value is ((0))/Discontinued default value is ((0))/


I have tested it in sql server, maybe it works in oracle too.




Thomas
Posted: Wednesday, February 17, 2010 7:01:28 PM
Rank: Advanced Member
Groups: Member

Joined: 7/30/2007
Posts: 59
Points: 177
Hi edu,

Great, thank you for your code snippet. We'll check if we can integrate it in the database schema examination and will let you know if or when it will be available in NConstruct software.




Regards
Thomas


NConstruct Support Team
support@nconstruct.com
http://www.nconstruct.com

Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by Yet Another Forum.net version 1.9.1.6 (NET v2.0) - 11/14/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.049 seconds.