Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6135757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:31:03+00:00 2026-05-23T17:31:03+00:00

Hi I want to write a model which will look like this: public class

  • 0

Hi I want to write a model which will look like this:

public class Profile : Models.Users {

    ModdDBEntities db = new ModdDBEntities();

    public Profile( int user_id ) {
        this = (Profile)( 
                    from u in db.Users.Where(r => r.user_id == user_id ) 
                    select u 
        ).First();
    }
}

Is there any method to assign a values of every properties to this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:31:04+00:00Added an answer on May 23, 2026 at 5:31 pm

    If you really want to copy all properties from one object to another, you can do this:

    foreach (var obj1Property in obj1.GetType().GetProperties())
    {
        var obj2Property = obj2.GetType().GetProperty(obj1Property.Name);
        obj2Property.SetValue(obj2, obj1Property.GetValue(obj1, null), null);
    }
    

    Where in your case, obj1 is the profile object, and obj2 is this.

    This only copies public properties, and of course, doesn’t check to ensure that obj2’s type declares all of the properties found in obj1’s type. Nor does it check that the same-named properties in both types are of the same type themselves. But it should get you started.

    Not that I’d recommend doing this except in very unusual cases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a new application that will use a DBMS. In the
I want to write a game in which there will be some balls on
I want to write a function which will take a series of fields and
I want to write an app that takes in a model filename via cmd
I want to write some JavaScript that will change the onmousedown of a div
I am building an application which will send status requests to users (via email
I am trying to write a stored procedure in MySQL which will perform a
Has anyone tried to dynamically select which properties they want to write to an
I am trying to write a view that will generate a report which displays
I want to write an app which is consist on two major parts: 1.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.