mapping value references

7 posts, 1 answers
  1. Fred
    Fred avatar
    45 posts
    Member since:
    Apr 2009

    Posted 25 Aug 2010 Link to this post

      Hi,
      I'm starting to evaluate open access and reading the docs i saw this: http://www.telerik.com/help/openaccess-orm/fields-mapping-value-references.html . It's a feature i really want but i have some doubts...

     1- say i want to map CustomerName in order class it will work too right ?
     2 - Can i do this using the visual designer? I Couldn't find this xml mapping in my test project.

    thanks in advance,
    Fred.
  2. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 26 Aug 2010 Link to this post

    Hi Fred,

    You won't find the xml (as in the docs) when you are using the Visual Designer, since the Visual Designer uses a new xml format. The xml in the docs is the old xml format.
    So basically what are you trying to achieve? To have the Name property of Order.Customer available as a property (say CustomerName) on the Order class?

    Regards

    Henrik
  3. DevCraft banner
  4. Fred
    Fred avatar
    45 posts
    Member since:
    Apr 2009

    Posted 26 Aug 2010 Link to this post

     Hi Henrik,
     Thanks for the response. Yes, this is what i'm trying to achieve.

     Fred.
  5. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 26 Aug 2010 Link to this post

    Hi Fred,

    Thanks for elaborating.

    If you need a "display only" property for your UI control (a Grid for example) you can extend the Order class, like (in pseudo code):

    public class Order
    {
       // Private
       private Customer customer;
    ..
    ..
    ..
       public string CustomerName
       {
          get { if (customer != null) return customer.Name else return null; }
       }
    }

    You might do this extension in a separate partial class..

    Regards

    Henrik
  6. Fred
    Fred avatar
    45 posts
    Member since:
    Apr 2009

    Posted 26 Aug 2010 Link to this post

    This will work, thanks!

    But, just to make sure, it's not possible to map this in designer or in xml ?

    Fred.

    edit:

      After some more digging in the documentation  i'm somewhat confused with the IobjectScope and OpenAcessContext objects. In the help files they show a "OpenAccess ORM Visual Designer" that show the Context object and a "OpenAccess ORM Classic" using the IObjectScope in the samples.

      Can someone explain the diference and when to use one or another?

    Fred.
  7. Answer
    TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 27 Aug 2010 Link to this post

    Hi Fred,

    I don't know if you can map it in the Visual Designer. The only reason I can think of why to map it is that you want content (here CustomerName) back in the database.

    Anyway.. the difference between the "Classic" and "Visual Designer" is merely the API and the tools used in Visual Studio.

    The "Classic" API uses the IObjectScope to gain access to persistent objects and other stuff you can do with them. But the "Visual Desginer" API uses the OpenAccessContext to gain access.
    Likewise, with the "Classic" you use the old wizards for modelling/mapping (they are in fact hidden from the OpenAccess menu in Visual Studio, but you can still have them shown in there if you want to). And the "Visual Designer" eh.. yeah... uses the Visual Designer for modelling/mapping.

    So the difference is (roughly said) on the surface (UI and API) that the developer uses to model, map and program against OpenAccess.

    Still if you are beginning a new project (or porting and existing non-OpenAccess project) targeting OpenAccess as ORM I would definitely advice you to use the "Visual Designer" way of doing stuff.
    Since, all new development efforts (as far as I have heard) will go into the new OpenAccessContext and Visual Designer. And "Classic" is in kind of "maintenance" mode

    Hope this clears things up.

    Regards

    Henrik
  8. Fred
    Fred avatar
    45 posts
    Member since:
    Apr 2009

    Posted 27 Aug 2010 Link to this post

    Thank you again!

    Fred.
Back to Top
DevCraft banner