Copy values from attributes with same name

4 posts, 0 answers
  1. Eduardo
    Eduardo avatar
    2 posts
    Member since:
    Apr 2013

    Posted 30 May 2013 Link to this post

    Hi all, my first post here, so if i'm doing anything  wrong please let me know ( also english inst my first language)

    I'm a PHP Developer, and now starting with C#, in a PHP Framework we have the following situation

    Object1 attributes
    Name
    Birthday
    email
    tel
    zipcode

    Then we have 
    Object 2 attributes
    Name
    Birthday
    email


    We can make multiple attribuitions, like Object1.attributes=Object2.attributes so all the attributes from Object1 that have the same name in Object2 will receive the values from Object2.

    Theres anything similar here on OpenAccess ORM?

    Thanks in advance!
    Eduardo Estevão
  2. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 04 Jun 2013 Link to this post

    Hello Eduardo,

    Thank you for your interest in OpenAccess ORM.

    When it comes to variables, the main difference between C# and PHP is that, C# is a type-safe language. In other words, in C# the compiler will throw build errors, if the type of the variable and the type of the assigned value do not match. In the case you describe, I would suggest that you assign the attribute values of Object manually, like this:

    Object1.Name = Object2.Name;
    Object1.Birthday = Object2.Birthday;
    Object1.Email = Object2.Email;

    Note that that would be a compilable code only if the types of the properties from Object1 match the types of the properties of Object2.

    Additionally, here you can find the C# Language specification that contains the basics of the language. The documentation for OpenAccess ORM is available here and I would also suggest to you our starter series on Telerik TV.

    I hope that helps. If you have additional questions or if you need to implement some specific scenario, do not hesitate to get back to us.


    Regards,
    Doroteya
    Telerik
    OpenAccess Samples Kit boasts 50+ sample applications providing diverse real-life business solutions. Click to read more and see OpenAccess ORM in action.
  3. DevCraft banner
  4. Eduardo
    Eduardo avatar
    2 posts
    Member since:
    Apr 2013

    Posted 05 Jun 2013 Link to this post

    Hi Doroteya, 

    Thanks for the clear answer!!

    I worked previously with java so i know a little about type-safe languages..i guess its probably the same with C#..

    If don't exists ok, but a suggestion..

    Scenario:

    Object1.Name (String)
    Object1.BirthDay(Date)
    Object1.Email(String)
    Object1.Tel (Int16)
    Object1.ID(Int32)


    Object2.Name(String)
    Object2.BirthDay(Date)
    Object1.Email(Int32)
    Object1.Tel(Int32)
    Object.ID(Int32)

    IF could exists something that does  Object1.attributes=Object2.attributes that clone the values from the object that have the same name and type, i think would improve a lot to productivity, because we have some big objects here, and a lot of hard work, just writing every attribute...

    I guess wont be so complicated to do this with reflection of somekind ( again, i'm starting with C# so thats why i cant provide a snippet or a idea of the code).

    But thanks anyway for the answer!
    OpenAccess ORM its a great framework!!

    Kind regards!
    Eduardo Estevão
  5. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 10 Jun 2013 Link to this post

    Hi Eduardo,

    Thank you for both the good words about OpenAccess ORM and the suggestion.

    Currently, we do not have such a feature in our product backlog. So, I would advise you to post that idea as a feature request on our Ideas and Feedback portal. There the developers that use OpenAccess ORM can review and vote for it. If it gathers the approval of the community, we would consider placing it on our roadmap.

    Do not hesitate to get back to us, if you have questions or experience difficulties.


    Regards,
    Doroteya
    Telerik
    OpenAccess Samples Kit boasts 50+ sample applications providing diverse real-life business solutions. Click to read more and see OpenAccess ORM in action.
Back to Top