Search   

Sunday, February 05, 2012

Support » Support Forum

Register  Login

 Menu  
 
    

 Welcome!  
 


Welcome to the NDO support forum!

kreis.gif Please register/login at the site if you want to post a thread. We sometimes copy support mails of common interest to the forum. They appear with anonymous sender.
kreis.gif Please post your messages in English language if possible. You can do your posts also in German, we will translate your post and our answer so that all users of the forum can read your posts.
kreis.gif The forum software requires that javascript is enabled.
kreis.gif Please do not insert licence information or licence keys in forum posts.
kreis.gif If you know a good answer to a post of another user, feel free to reply!
kreis.gif The forum is monitored. We reserve the right to remove posts we consider not to be useful for other forum users.

   Print   

      
 NDO Support Forum  
 
SearchForum Home
  NDO-Forum postings in english please, if possible.  Developing with NDO  NDO Tutorial Sa...
 NDO Tutorial Sample in VB
 
 12/3/2006 12:04:50 PM
didikunz
9 posts
www.mediasupport.ch


NDO Tutorial Sample in VB
 Modified By Mirko  on 12/5/2006 11:53:30 AM)
Hello Mirko,

in the help there is an example to query a Picture object fro a PictuteHeader mapped to the same table. It is in C#:

PersistenceManager pm = new PersistenceManager();
Query q = pm.NewQuery(typeof(PictureHeader), null);
IList l = q.Execute();
// Normally we'd show the headers in an UI
foreach (PictureHeader ph in l)
Console.WriteLine(ph.Name);

// Select a PictureHeader and find the corresponding Picture
Picture p = (Picture) pm.FindObject(typeof(Picture), ((PictureHeader)l[0]).NDOObjectId.Id.Value);
Image image = p.Image;
Console.WriteLine("Picture: " + p.Name + ": " + image.Height.ToString() + "x" + image.Width.ToString());

If I translate it to VB.NET using ASPAlliance.com translator it looks like this:

Dim pm As New PersistenceManager()
Dim q As Query = pm.NewQuery(GetType(PictureHeader), Nothing)
Dim l As IList = q.Execute()
' Normally we'd show the headers in an UI
Dim ph As PictureHeader
For Each ph In l
Console.WriteLine(ph.Name)
Next ph
' Select a PictureHeader and find the corresponding Picture
Dim p As Picture = CType(pm.FindObject(GetType(Picture), CType(l(0), PictureHeader).NDOObjectId.Id.Value), Picture)
Dim image As Image = p.Image
Console.WriteLine(("Picture: " + p.Name + ": " + image.Height.ToString() + "x" + image.Width.ToString()))

If I do something similar with my own objects (also mapped to the same table) it says: 'NDOObjectId is not part of Object soandso.' Is the VB.NET syntax correct? Must I do something with my object or the mapping? Or is it simply not possible in VB.NET 2005?

Regards: Didi
 12/4/2006 8:01:38 AM
didikunz
9 posts
www.mediasupport.ch


Re: Inheritance without Polymorphy in VB
...I found out, that it works, if I set the reference in my callig project to the dll instead of the project. But what I did not found out is, how can I make Visual Studio to update the referenced dll each time I regenerate (probably I just need to search the VS docs). Regards: Didi
 12/5/2006 10:51:18 AM
Mirko
109 posts
5th


Re: Inheritance without Polymorphy in VB

Hi Didi,

there is a simpler way: Just convert l(0) into an IPersistenceCapable instead of a CPictureHeader.

Dim p As Picture = CType(pm.FindObject(GetType(Picture), CType(l(0), IPersistenceCapable).NDOObjectId.Id.Value), Picture)

Then the code works with project references too.

Best Regards:
Mirko

 12/5/2006 12:53:25 PM
didikunz
9 posts
www.mediasupport.ch


Re: Inheritance without Polymorphy in VB
Hi Mirko,

it realy worked that way! Thank you very much!

Regards: Didi
  NDO-Forum postings in english please, if possible.  Developing with NDO  NDO Tutorial Sa...
  SearchSearch  Forum HomeForum Home