Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
using OMOBranch.DAL;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;


namespace OMOBranch.Models
{
    public class Institution
    {
        [Key]
        [Required]
        [Display(Name = "Institution Id")]
        public int IntId { get; set; }
        [Required]
        [Display(Name = "Branch Name", Description = "እባክዎን የቅርጫፍ ስም ያስገቡ")]
        public int BId { get; set; }


        [Required]
        [Display(Name = "Employee Name")]
        public int EmpId { get; set; }
        
        [Required(AllowEmptyStrings = false, ErrorMessage = "ጾታ ባዶ መሆን አይችልም!!!")]
        [Display(Name = "ጾታ ")]
        public ListCreator.SexA SexA { get; set; }
        [Required]
        [Display(Name = "Description")]
        public ListCreator.Description Description{ get; set; }
        [Required]
        [Display(Name = "Institution Type")]
        public ListCreator.InstitutionType InstitutionType{ get; set; }
        [Required]
        [Display(Name = "Weekly Balance")]
        public decimal WeeklyBalance { get; set; }
        [Required]
        [Display(Name = "Previous Balance")]

        public decimal PreviousBalance
        {
            get { return (Cummulative); } 

        }
            
        
     
        [Required]
        [Display(Name = "Cummulative")]
        public decimal Cummulative
        {
            get { return decimal.Add(WeeklyBalance, PreviousBalance); }
        }

        [Required]
        [Display(Name = "ቀን")]
        public DateTime Date { get; set; }
        public virtual Branch branch { get; set; }
        public virtual Employee employee { get; set; }
        

        

        public ApplicationDbContext db = new ApplicationDbContext();
 

    }
}


What I have tried:

am the begginner programmer on MVC5 I haven't try
Posted
Updated 29-Jan-17 22:13pm
v2

1 solution

You get a stack overflow when something gets into an infinite function call loop, like this

public void MethodA()
{
    MethodA();
}


In the above MethodA calls itself and every time this happens it reserves space on the stack but the stack is finite so eventually it calls itself so many times the stack runs out of space.

In your code Cummulative calls PreviousBalance which calls Cummulative so if you try and access PreviousBalance you end up in an infinite call loop.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900