edge icon indicating copy to clipboard operation
edge copied to clipboard

edge + entity framework

Open mdavid5 opened this issue 9 years ago • 9 comments

Hi, I have a problem with edge js when I am trying use an object with lists.

(I have tested it with a simple console app without any problem)

The scenario is the following:

  • entity framework generated classes
  • simple get method
  • node js dies on stackoverflow exception (I guess edge js handles something badly)

code:

The class:

namespace DataLayerLibrary { using System; using System.Collections.Generic;

public partial class User
{
    public User()
    {
        //this.Restaurant = new HashSet<Restaurant>();
        //this.Search = new HashSet<Search>();
        //this.UserLocation = new HashSet<UserLocation>();
    }

    public int UserId { get; set; }
    public string Name { get; set; }
    public string Email { get; set; }
    public string Phone { get; set; }
    public string PasswordHash { get; set; }
    public int UserTypeId { get; set; }

//These properties cause the StackOverflow Exception ... somehow

    //public virtual ICollection<Restaurant> Restaurant { get; set; }
    //public virtual ICollection<Search> Search { get; set; }
    //public virtual ICollection<UserLocation> UserLocation { get; set; }
}

}

Task:

public async Task GetUserByIdTask(dynamic input) { try { int id; var validInput = int.TryParse((string)input, out id);

            if(!validInput) throw new ArgumentException("The parameter is not a number.");

            return await Task.FromResult(GetUserById(id));
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
   }

}

Get method:

public User GetUserById(int id) { using (var da = _container.Resolve<DbEntities>()) { return da.User.FirstOrDefault(user => user.UserId == id); } }

If I remove the Collections from the User class, it works perfectly. What is the cause?

Thanks, David

mdavid5 avatar Mar 09 '15 00:03 mdavid5