Multiple 'Findby' functions in typed dataset table?

S

Simon Storr

I have a typed dataset table with a primary key (id) and another unique key
(name). Generating the dataset creates FindById for the primary key, but
won't create 'FindByName', even though name is unique (I had to hack the XML
to make the key unique by changing the xs:key tag to xs:unique). I've tried
tricking it into thinking that name is also a PK but it then only creates
FindByName! The only way I've found to do a find on name is a hack using the
DefaultView client side which is far from ideal :blush:( Is it possible to have
multiple 'FindBy's generated for one table?

TIA!

Simon
 
S

Steve Drake

Could you create a sub class of the typed dataset that implements your
findby(s)?

I haven't tried this, but I don't see why it shouldn't work.

Steve
 
K

Kevin Yu [MSFT]

Hi Simon,

FindBy methods are only generated for primary keys. VS .Net doesn't
generate them for columns that are only unique. This feature is by design.
As Steve says, you can create a sub class of the typed DataSet and
implements your own FindBy method.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Steve Drake" <Steve@_NOSPAM_Drakey.co.uk>
| References: <[email protected]>
| Subject: Re: Multiple 'Findby' functions in typed dataset table?
| Date: Tue, 4 Nov 2003 15:51:57 -0000
| Lines: 29
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: no-dns-yet.demon.co.uk 80.177.235.38
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65365
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| Could you create a sub class of the typed dataset that implements your
| findby(s)?
|
| I haven't tried this, but I don't see why it shouldn't work.
|
| Steve
|
| | > I have a typed dataset table with a primary key (id) and another unique
| key
| > (name). Generating the dataset creates FindById for the primary key, but
| > won't create 'FindByName', even though name is unique (I had to hack the
| XML
| > to make the key unique by changing the xs:key tag to xs:unique). I've
| tried
| > tricking it into thinking that name is also a PK but it then only
creates
| > FindByName! The only way I've found to do a find on name is a hack using
| the
| > DefaultView client side which is far from ideal :blush:( Is it possible to
have
| > multiple 'FindBy's generated for one table?
| >
| > TIA!
| >
| > Simon
| >
| >
|
|
|
 
S

Simon Storr

Thanks, I will try that but I'm wary of doing it as the typed dataset is
auto-generated. Why is this by design? If its a unique key unique why can't
such a method be implemented? In a future version even a non-unique key
could return a rowset?

cheers,

Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top