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 6162211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:36:51+00:00 2026-05-23T21:36:51+00:00

I don’t know is it possible to do. I have two classes: public class

  • 0

I don’t know is it possible to do. I have two classes:

public class Document
    {
  public uint location;

    public Document(uint documentId)
    {
        // Here complex logic of retrieving information from DB follows
        OracleCommand documentCommand = new OracleCommand("select field1, field2, field3 from table(usr.common_pck.GetDocument(:pDocumentId))", conn);
        documentCommand.Parameters.Add("pDocumentId", documentId);
        OracleDataReader documentReader = documentCommand.ExecuteReader();
        if (documentReader.HasRows)
        {
            this.id = documentId;
            this.serial = documentReader.GetString("field2");
            this.location = Convert.ToUInt32(documentReader.GetInt32("field1"));    
            // Here I want to call "manualSetLocationStr(field3)" of DocumentViewModel
        }
    }
}

And here second class:

     public class DocumentViewModel : Document {
            private OracleConnection connection;
            private string _locationStr { get; set; }

            protected void manualSetLocationStr(string value)
            {
                _locationStr = value;
            }

            public string typeStr { get { return ((Dictionary<int, string>)HttpContext.Current.Application["DocumentTypesList"]).Single(mbox => mbox.Key == type).Value; } }

public string locationStr { 
                get {
                    if (_locationStr == null) {
                        OracleCommand getNameCommand = new OracleCommand("select usr.common_pck.GetName(:id) as name from dual", connection);
                        getNameCommand.Parameters.Add("id", this.location);
                        OracleDataReader NameReader = getNameCommand.ExecuteReader();
                        NameReader.Read();
                        _locationStr = NameReader.GetString("name");
                    }
                    return _locationStr;
                } 
            }    
        }

So my question is how can I call manualSetLocationStr() in contructor of Document? I need this to avoid second retrieving information from DB in locationStr get accessor, ’cause I already have it (this is field3 in Document contructor).
Any advice, any thoughs will be very appreciated.
Strongly hope for your help!
Thanks in advance!

  • 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-23T21:36:51+00:00Added an answer on May 23, 2026 at 9:36 pm

    Why can’t the field3 value be stored as a property of Document? Also, it is more standard for view models to contain an instance of their model, rather than derive from them.

    Update

    It depends on your architecture, but you could create a DocumentInfo type for example which has all of the properties required for your view. Then you need to populate a collection of these for your view, you can use a DocumentInfoRepository which provides the abstraction over the data access. This repository can either be accessed directly in your entity or from your controller, depending on the type of your domain model and the patterns you wish to employ.

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

Sidebar

Related Questions

Don't you hate it when you have class Foobar { public: Something& getSomething(int index)
I don't know if this is possible. I display a table of results and
Don't know if this has been answered before. Have custom routes to users. If
I don't have much PHP experience and I want to know how to best
I don't have a Global Application class code-behind any more inside my installed templates.
I don't know when to add to a dataset a tableadapter or a query
I don't know if anyone has seen this issue before but I'm just stumped.
I don't know why i can't match url when url is http://localhost:8000/home/CPM%201.6.1001 since i
I don't know Regex very well, and I'm trying to get all of the
I don't know if thats right but for some reason my stored procedure is

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.