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

  • Home
  • SEARCH
  • 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 6788053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:26:19+00:00 2026-05-26T17:26:19+00:00

With help from StackOverflow today, I have gotten my data layer constructed return data

  • 0

With help from StackOverflow today, I have gotten my data layer constructed return data from my XML file to my Business Logic Layer. However, I can’t seem to get the data from my business objects layer. The values are all null. Sorry, to be such a newbie…. Thanks in advance.

Business logic layer:

public void getCustDetails(string customerId)
{                          
    DLGetCustomers obj = new DLGetCustomers();
    obj.getCustDetails(customerId);
    AccountDetails obj1 = new AccountDetails();
    FirstName = obj1.Fname;
    LastName = obj1.Lname;
    SSN = obj1.Ssn;
    Dob = Convert.ToDateTime(obj1.Dob);
    CustomerId = Convert.ToInt32(obj1.Custid);
    TimeSpan ts = DateTime.Now - Convert.ToDateTime(Dob);
    Age = ts.Days / 365;
}

Data access layer:

public class AccountDetails
{
    public string Fname { get; set; }
    public string Lname { get; set; }
    public string Ssn { get; set; }
    public string Dob { get; set; }
    public string Custid { get; set; }
} 

public IEnumerable<AccountDetails> getCustDetails(string customerId)
{
    //Pulls customer information for selected customer 
    var doc = XDocument.Load("Portfolio.xml");
    var custRecords = from account in doc.Descendants("acct")
                      let acct = account.Element("acct")
                      where (string)account.Attribute("custid").Value == customerId
                      select new AccountDetails
                      {
                          Fname = (string)account.Attribute("fname").Value,
                          Lname = (string)account.Attribute("lname").Value,
                          Ssn = (string)account.Attribute("ssn").Value,
                          Dob = (string)account.Attribute("dob").Value,
                          Custid = (string)account.Attribute("custid").Value
                      };                          

    return custRecords;
}
  • 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-26T17:26:20+00:00Added an answer on May 26, 2026 at 5:26 pm

    This line:

    AccountDetails obj1 = new AccountDetails();
    

    Simply sets obj1 to a new instance of AccountDetails which would be full of empty strings.

    You probably need to change getCustDetails in your DAL to return an instance of AccountDetails instead of an IEnumerable of it, and set obj1 to that:

    AccountDetails obj1 = obj.getCustDetails(customerId);
    

    In your DAL:

    public AccountDetails getCustDetails(string customerId)
    {
        //Pulls customer information for selected customer 
        var doc = XDocument.Load("Portfolio.xml");
        var custRecords = from account in doc.Descendants("acct")
                          let acct = account.Element("acct")
                          where (string)account.Attribute("custid").Value == customerId
                          select new AccountDetails
                          {
                              Fname = (string)account.Attribute("fname").Value,
                              Lname = (string)account.Attribute("lname").Value,
                              Ssn = (string)account.Attribute("ssn").Value,
                              Dob = (string)account.Attribute("dob").Value,
                              Custid = (string)account.Attribute("custid").Value
                          };
    
    
        return custRecords.FirstOrDefault();
    } 
    

    Note that if your DAL can’t find an account with the specified customerId, it will return a null (which is the default value of a class). You will need to check the return value against null before using if you do not want a NullReferenceException to be thrown in such an eventuality.

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

Sidebar

Related Questions

thanks to help from stackoverflow posters I have set up some oop javascript. However,
With the help from good samaritans from stackoverflow, I have come till the following
With some kindly help from StackOverflow, I've got Unity Framework to create my chained
Dear Friends from Stackoverflow, Please help me with a problem that i'm having when
First, thanks for all the help I've received so far from StackOverflow. I've learned
With help from you guys I now have a script that works like a
I need some help from the shell-script gurus out there. I have a .txt
cowboy coder needs some help from SO-veterans: I have a given application that uses
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
Hello StackOverflow community, The air.swf file referenced here: http://livedocs.adobe.com/flex/3/html/help.html?content=distributing_apps_3.html used to launch AIR applications

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.