Discussion:
Managed enums
Andrew Eames
2007-10-22 15:17:37 UTC
Permalink
Hi,
According to the the MSDN docs http://msdn2.microsoft.com/en-
us/library/a6cskb49(VS.80).aspx

Quote
If a standard C++ enum is defined (without class or struct), compiling
with /clr will cause the enumeration to be compiled as a managed enum. The
enumeration still has the semantics of an unmanaged enumeration. Note, the
compiler injects an attribute, Microsoft::VisualC::NativeEnumAttribute,
which the Visual C++ compiler recognizes, to identify a programmer's
intent for the enum to be a native enum. Other compilers will simply see
the standard enum as a managed enum.
/Quote

When I do this, the enum is marked as internal so this is not actually
very helpful - is there a way to make it public (other than making it a
managed enum) - I dont see the NativeEnumAttribute either
Thanks
Andrew

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Peter Ritchie
2007-10-22 18:01:13 UTC
Permalink
On Mon, 22 Oct 2007 11:17:37 -0400, Andrew Eames <***@COGNEX.COM> wrote:
>When I do this, the enum is marked as internal so this is not actually
>very helpful - is there a way to make it public (other than making it a
>managed enum) - I dont see the NativeEnumAttribute either

The problem is that default access is internal. To override that you need
to specific either the access on the enum or its parent class. Unmanaged
C++ doesn't have that concept and you'd have to used C++/CLI syntax which
only applies to managed types.

I know of nothing that changes the default access to be something other
than internal for a project or a module.

I also see nothing in the .NET 1.0, 1.1, or 2.0 assemblies about
NativeEnumAttribute. My guess is the documentation is wrong and
NativeEnumAttribute is replaced by ScopelessEnumAttribute.

You should be able to use a managed enum in native code in the same
module, if that's what you need to do.

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Eames, Andrew
2007-10-22 18:22:43 UTC
Permalink
Alan Baljeu
2007-11-21 14:30:39 UTC
Permalink
Shawn Wildermuth
2007-11-21 18:52:07 UTC
Permalink
Sébastien Lorion
2007-11-22 04:08:58 UTC
Permalink
You may want to take a look at my CSV reader found on Code Project:

http://www.codeproject.com/cs/database/CsvReader.asp

Sebastien

On 11/21/07, Alan Baljeu <***@cornerstonemold.com> wrote:
> My application uses a largish readonly database (CSV files, actually) consisting of several
> tables. These tables are accessed somewhat frequently, and I want to make this as efficient
> as possible. I'm currently using plain DataTable objects produced by OdbcAdapters and
> queries. These tables are cached so I'm just searching in-memory tables after that. My
> queries look like "SELECT * FROM [{0}]" and occasionally "SELECT * FROM [{0}] where [{1}] =
> '{2}'". I'm thinking of splitting the latter into just table.Select("colname = value").
>
> I have a nagging suspicion that the DataTable structure isn't super-efficient, or that
> certain ways of using it are effcient while others aren't.
>
> Is this so? Are there certain things I should avoid? Do you recommend a certain style for
> efficient access? Is there a better approach that DataTable?
>
> ===================================
> This list is hosted by DevelopMentor(R) http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>


--
Sébastien
www.sebastienlorion.com

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Alan Baljeu
2007-11-22 16:37:04 UTC
Permalink
I like it in concept, but... Currently I'm using the ODBC driver to read these files. It
uses schema.ini to convert specified columns to bool or int. Your code just gives me
strings. Have you any suggestion on how I might adapt the CSV reader to parse columns
according to a schema? Initially I imagine putting this stuff into DataTables because
anything else will require much code conversion.

> -----Original Message-----
> From: Discussion relating to the specifics of the C# and
> Managed C++ languages [mailto:DOTNET-***@DISCUSS.DEVELOP.COM]
> On Behalf Of Sébastien Lorion
> Sent: Wednesday, November 21, 2007 11:09 PM
> To: DOTNET-***@DISCUSS.DEVELOP.COM
> Subject: Re: [DOTNET-CX] DataTable efficiency
>
> You may want to take a look at my CSV reader found on Code Project:
>
> http://www.codeproject.com/cs/database/CsvReader.asp
>
> Sebastien
>
> On 11/21/07, Alan Baljeu <***@cornerstonemold.com> wrote:
> > My application uses a largish readonly database (CSV files,
> actually)
> > consisting of several tables. These tables are accessed somewhat
> > frequently, and I want to make this as efficient as
> possible. I'm currently using plain DataTable objects
> produced by OdbcAdapters and
> > queries. These tables are cached so I'm just searching
> in-memory tables after that. My
> > queries look like "SELECT * FROM [{0}]" and occasionally
> "SELECT * FROM [{0}] where [{1}] =
> > '{2}'". I'm thinking of splitting the latter into just
> table.Select("colname = value").
> >
> > I have a nagging suspicion that the DataTable structure isn't
> > super-efficient, or that certain ways of using it are
> effcient while others aren't.
> >
> > Is this so? Are there certain things I should avoid? Do you
> > recommend a certain style for efficient access? Is there a
> better approach that DataTable?
> >
> > ===================================
> > This list is hosted by DevelopMentor(R) http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> > http://discuss.develop.com
> >
>
>
> --
> Sébastien
> www.sebastienlorion.com
>
> ===================================
> This list is hosted by DevelopMentor® http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Brady Kelly
2007-11-22 17:22:26 UTC
Permalink
Have a look at the File Helpers library. In my limited experiments, I found
that a good match for predefined formats, and a bit restrictive for general
cases, as it uses attributes on members to define columns. I found
Sebastien's library very nice for general cases, but restrictive in only
handling char delimiters. Both are excellent pieces of work, however, and
I'm sure can be adapted to most situations.

-----Original Message-----
From: Discussion relating to the specifics of the C# and Managed C++
languages [mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Alan Baljeu
Sent: 22 November 2007 06:37 PM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-CX] DataTable efficiency

I like it in concept, but... Currently I'm using the ODBC driver to read
these files. It
uses schema.ini to convert specified columns to bool or int. Your code just
gives me
strings. Have you any suggestion on how I might adapt the CSV reader to
parse columns
according to a schema? Initially I imagine putting this stuff into
DataTables because
anything else will require much code conversion.

> -----Original Message-----
> From: Discussion relating to the specifics of the C# and
> Managed C++ languages [mailto:DOTNET-***@DISCUSS.DEVELOP.COM]
> On Behalf Of Sébastien Lorion
> Sent: Wednesday, November 21, 2007 11:09 PM
> To: DOTNET-***@DISCUSS.DEVELOP.COM
> Subject: Re: [DOTNET-CX] DataTable efficiency
>
> You may want to take a look at my CSV reader found on Code Project:
>
> http://www.codeproject.com/cs/database/CsvReader.asp
>
> Sebastien
>
> On 11/21/07, Alan Baljeu <***@cornerstonemold.com> wrote:
> > My application uses a largish readonly database (CSV files,
> actually)
> > consisting of several tables. These tables are accessed somewhat
> > frequently, and I want to make this as efficient as
> possible. I'm currently using plain DataTable objects
> produced by OdbcAdapters and
> > queries. These tables are cached so I'm just searching
> in-memory tables after that. My
> > queries look like "SELECT * FROM [{0}]" and occasionally
> "SELECT * FROM [{0}] where [{1}] =
> > '{2}'". I'm thinking of splitting the latter into just
> table.Select("colname = value").
> >
> > I have a nagging suspicion that the DataTable structure isn't
> > super-efficient, or that certain ways of using it are
> effcient while others aren't.
> >
> > Is this so? Are there certain things I should avoid? Do you
> > recommend a certain style for efficient access? Is there a
> better approach that DataTable?
> >
> > ===================================
> > This list is hosted by DevelopMentor(R) http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> > http://discuss.develop.com
> >
>
>
> --
> Sébastien
> www.sebastienlorion.com
>
> ===================================
> This list is hosted by DevelopMentor® http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Alan Baljeu
2007-11-22 17:36:12 UTC
Permalink
Sébastien Lorion
2007-11-23 00:29:25 UTC
Permalink
You can create the DataTable before hand and then use the Load method
(the CsvReader implement IDataReader).

Sébastien

On 11/23/07, Alan Baljeu <***@cornerstonemold.com> wrote:
> I like it in concept, but... Currently I'm using the ODBC driver to read these files. It
> uses schema.ini to convert specified columns to bool or int. Your code just gives me
> strings. Have you any suggestion on how I might adapt the CSV reader to parse columns
> according to a schema? Initially I imagine putting this stuff into DataTables because
> anything else will require much code conversion.
>
> > -----Original Message-----
> > From: Discussion relating to the specifics of the C# and
> > Managed C++ languages [mailto:DOTNET-***@DISCUSS.DEVELOP.COM]
> > On Behalf Of Sébastien Lorion
> > Sent: Wednesday, November 21, 2007 11:09 PM
> > To: DOTNET-***@DISCUSS.DEVELOP.COM
> > Subject: Re: [DOTNET-CX] DataTable efficiency
> >
> > You may want to take a look at my CSV reader found on Code Project:
> >
> > http://www.codeproject.com/cs/database/CsvReader.asp
> >
> > Sebastien
> >
> > On 11/21/07, Alan Baljeu <***@cornerstonemold.com> wrote:
> > > My application uses a largish readonly database (CSV files,
> > actually)
> > > consisting of several tables. These tables are accessed somewhat
> > > frequently, and I want to make this as efficient as
> > possible. I'm currently using plain DataTable objects
> > produced by OdbcAdapters and
> > > queries. These tables are cached so I'm just searching
> > in-memory tables after that. My
> > > queries look like "SELECT * FROM [{0}]" and occasionally
> > "SELECT * FROM [{0}] where [{1}] =
> > > '{2}'". I'm thinking of splitting the latter into just
> > table.Select("colname = value").
> > >
> > > I have a nagging suspicion that the DataTable structure isn't
> > > super-efficient, or that certain ways of using it are
> > effcient while others aren't.
> > >
> > > Is this so? Are there certain things I should avoid? Do you
> > > recommend a certain style for efficient access? Is there a
> > better approach that DataTable?
> > >
> > > ===================================
> > > This list is hosted by DevelopMentor(R) http://www.develop.com
> > >
> > > View archives and manage your subscription(s) at
> > > http://discuss.develop.com
> > >
> >
> >
> > --
> > Sébastien
> > www.sebastienlorion.com
> >
> > ===================================
> > This list is hosted by DevelopMentor(R) http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> > http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor(R) http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>


--
Sébastien
www.sebastienlorion.com

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Sébastien Lorion
2007-11-23 07:19:09 UTC
Permalink
Sorry, just realized that the DataTable.Load method is available only
in .NET 2.0.... In that case, you will need to derive a class from
DbDataAdapter in order to expose the protected method
DbDataAdapter.Fill(DataTable, IDataReader).

Sébastien

On 11/23/07, Sébastien Lorion <***@gmail.com> wrote:
> You can create the DataTable before hand and then use the Load method
> (the CsvReader implement IDataReader).
>
> Sébastien
>
> On 11/23/07, Alan Baljeu <***@cornerstonemold.com> wrote:
> > I like it in concept, but... Currently I'm using the ODBC driver to read these files. It
> > uses schema.ini to convert specified columns to bool or int. Your code just gives me
> > strings. Have you any suggestion on how I might adapt the CSV reader to parse columns
> > according to a schema? Initially I imagine putting this stuff into DataTables because
> > anything else will require much code conversion.
> >
> > > -----Original Message-----
> > > From: Discussion relating to the specifics of the C# and
> > > Managed C++ languages [mailto:DOTNET-***@DISCUSS.DEVELOP.COM]
> > > On Behalf Of Sébastien Lorion
> > > Sent: Wednesday, November 21, 2007 11:09 PM
> > > To: DOTNET-***@DISCUSS.DEVELOP.COM
> > > Subject: Re: [DOTNET-CX] DataTable efficiency
> > >
> > > You may want to take a look at my CSV reader found on Code Project:
> > >
> > > http://www.codeproject.com/cs/database/CsvReader.asp
> > >
> > > Sebastien
> > >
> > > On 11/21/07, Alan Baljeu <***@cornerstonemold.com> wrote:
> > > > My application uses a largish readonly database (CSV files,
> > > actually)
> > > > consisting of several tables. These tables are accessed somewhat
> > > > frequently, and I want to make this as efficient as
> > > possible. I'm currently using plain DataTable objects
> > > produced by OdbcAdapters and
> > > > queries. These tables are cached so I'm just searching
> > > in-memory tables after that. My
> > > > queries look like "SELECT * FROM [{0}]" and occasionally
> > > "SELECT * FROM [{0}] where [{1}] =
> > > > '{2}'". I'm thinking of splitting the latter into just
> > > table.Select("colname = value").
> > > >
> > > > I have a nagging suspicion that the DataTable structure isn't
> > > > super-efficient, or that certain ways of using it are
> > > effcient while others aren't.
> > > >
> > > > Is this so? Are there certain things I should avoid? Do you
> > > > recommend a certain style for efficient access? Is there a
> > > better approach that DataTable?
> > > >
> > > > ===================================
> > > > This list is hosted by DevelopMentor(R) http://www.develop.com
> > > >
> > > > View archives and manage your subscription(s) at
> > > > http://discuss.develop.com
> > > >
> > >
> > >
> > > --
> > > Sébastien
> > > www.sebastienlorion.com
> > >
> > > ===================================
> > > This list is hosted by DevelopMentor(R) http://www.develop.com
> > >
> > > View archives and manage your subscription(s) at
> > > http://discuss.develop.com
> >
> > ===================================
> > This list is hosted by DevelopMentor(R) http://www.develop.com
> >
> > View archives and manage your subscription(s) at http://discuss.develop.com
> >
>
>
> --
> Sébastien
> www.sebastienlorion.com
>


--
Sébastien
www.sebastienlorion.com

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Alan Baljeu
2007-11-27 14:36:25 UTC
Permalink
One of the problems I have with ADO.net, is Microsoft forgot to mention exactly how
efficient their code is. This doesn't matter for a lot of things, but with database stuff
and lots of data, people would like to know. If I load data into a stream, and then feed
that stream to a datatable, how long does that take, or what steps does the system follow?
If I add the two tables and then create a DataRelation, is creating the relation fast or
slow? What datastructure is built? How are the tables indexed? Is there some mysterious
overhead due to the tremendous generality of the system?

Is your CSV reader more efficient because it bypasses ODBC, or is there more gains here?
Etc. It's almost enough to make me want to roll my own, so I know and can change things if
I'm not satisfied.


> -----Original Message-----
> From: Discussion relating to the specifics of the C# and
> Managed C++ languages [mailto:DOTNET-***@DISCUSS.DEVELOP.COM]
> On Behalf Of Sébastien Lorion
> Sent: Friday, November 23, 2007 2:19 AM
> To: DOTNET-***@DISCUSS.DEVELOP.COM
> Subject: Re: [DOTNET-CX] DataTable efficiency
>
> Sorry, just realized that the DataTable.Load method is
> available only in .NET 2.0.... In that case, you will need to
> derive a class from DbDataAdapter in order to expose the
> protected method DbDataAdapter.Fill(DataTable, IDataReader).
>
> Sébastien
>
> On 11/23/07, Sébastien Lorion <***@gmail.com> wrote:
> > You can create the DataTable before hand and then use the
> Load method
> > (the CsvReader implement IDataReader).
> >
> > Sébastien
> >
> > On 11/23/07, Alan Baljeu <***@cornerstonemold.com> wrote:
> > > I like it in concept, but... Currently I'm using the ODBC
> driver to
> > > read these files. It uses schema.ini to convert
> specified columns
> > > to bool or int. Your code just gives me strings. Have you any
> > > suggestion on how I might adapt the CSV reader to parse columns
> > > according to a schema? Initially I imagine putting this
> stuff into DataTables because anything else will require much
> code conversion.

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Sébastien Lorion
2007-11-28 01:50:11 UTC
Permalink
As Rico Mariani would say: measure, measure, measure ...

If you need memory efficiency, I would recommend you try to change
your algorithm to make it fully streaming. If that is impossible, then
you can measure the use of DataTable vs the CachedCsvReader class
included in my library and compare. I did not do that measurement
myself, but I would assume CachedCsvReader is more efficient since it
is much more simple (ArrayList of string arrays). On the other hand,
you will lose speed as you need to convert your data from string
everytime you access them. Of course, you can roll your own class
based on mine and store converted values instead of strings (ie
ArrayList of object arrays).

Btw, you may want to try DataTable.Select(...) instead of using
relations. It may or may not be faster, depending on your usage.

Sébastien

On 11/27/07, Alan Baljeu <***@cornerstonemold.com> wrote:
> One of the problems I have with ADO.net, is Microsoft forgot to mention exactly how
> efficient their code is. This doesn't matter for a lot of things, but with database stuff
> and lots of data, people would like to know. If I load data into a stream, and then feed
> that stream to a datatable, how long does that take, or what steps does the system follow?
> If I add the two tables and then create a DataRelation, is creating the relation fast or
> slow? What datastructure is built? How are the tables indexed? Is there some mysterious
> overhead due to the tremendous generality of the system?
>
> Is your CSV reader more efficient because it bypasses ODBC, or is there more gains here?
> Etc. It's almost enough to make me want to roll my own, so I know and can change things if
> I'm not satisfied.
>
>
> > -----Original Message-----
> > From: Discussion relating to the specifics of the C# and
> > Managed C++ languages [mailto:DOTNET-***@DISCUSS.DEVELOP.COM]
> > On Behalf Of Sébastien Lorion
> > Sent: Friday, November 23, 2007 2:19 AM
> > To: DOTNET-***@DISCUSS.DEVELOP.COM
> > Subject: Re: [DOTNET-CX] DataTable efficiency
> >
> > Sorry, just realized that the DataTable.Load method is
> > available only in .NET 2.0.... In that case, you will need to
> > derive a class from DbDataAdapter in order to expose the
> > protected method DbDataAdapter.Fill(DataTable, IDataReader).
> >
> > Sébastien
> >
> > On 11/23/07, Sébastien Lorion <***@gmail.com> wrote:
> > > You can create the DataTable before hand and then use the
> > Load method
> > > (the CsvReader implement IDataReader).
> > >
> > > Sébastien
> > >
> > > On 11/23/07, Alan Baljeu <***@cornerstonemold.com> wrote:
> > > > I like it in concept, but... Currently I'm using the ODBC
> > driver to
> > > > read these files. It uses schema.ini to convert
> > specified columns
> > > > to bool or int. Your code just gives me strings. Have you any
> > > > suggestion on how I might adapt the CSV reader to parse columns
> > > > according to a schema? Initially I imagine putting this
> > stuff into DataTables because anything else will require much
> > code conversion.
>
> ===================================
> This list is hosted by DevelopMentor(R) http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>


--
Sébastien
www.sebastienlorion.com

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Marc Brooks
2007-11-28 05:11:08 UTC
Permalink
> As Rico Mariani would say: measure, measure, measure ...

+1

> Btw, you may want to try DataTable.Select(...) instead of using
> relations. It may or may not be faster, depending on your usage.

A couple articles popped to mind:
http://www.aspheute.com/english/20040123.asp
http://blog.hill-it.be/post/2007/10/03/DataView-vs-DataTableSelect

--
"He uses statistics as a drunken man uses lamp-posts… for support
rather than illumination." Andrew Lang
Alan Baljeu
2007-11-29 19:33:49 UTC
Permalink
Chris Anderson
2007-11-29 20:36:33 UTC
Permalink
Chris Anderson
2007-11-27 20:17:13 UTC
Permalink
Alan Baljeu
2007-11-21 18:38:02 UTC
Permalink
Hewitt, Simon C. (Contractor)
2007-11-22 06:08:02 UTC
Permalink
Loading...