This is a migrated thread and some comments may be shown as answers.

Copy values from attributes with same name

3 Answers 87 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eduardo
Top achievements
Rank 1
Eduardo asked on 30 May 2013, 11:15 PM
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

3 Answers, 1 is accepted

Sort by
0
Doroteya
Telerik team
answered on 04 Jun 2013, 09:38 PM
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.
0
Eduardo
Top achievements
Rank 1
answered on 05 Jun 2013, 01:11 PM
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
0
Doroteya
Telerik team
answered on 10 Jun 2013, 11:49 AM
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.
Tags
Getting Started
Asked by
Eduardo
Top achievements
Rank 1
Answers by
Doroteya
Telerik team
Eduardo
Top achievements
Rank 1
Share this question
or