'Getting proxy information while retrieving data by fluent hibernate

I have not used much fluent NHibernate so I am confused. When I try to get the information I get the wrong info as shown below. Any tips? This happens when I save a new item, so the problem is in the saving new item part.

    //Not expected
    [
    {
    "Id": 1,
    "DeviceName": "DEV1",
    "DeviceGroup": {
    "_proxyFactoryInfo": {
    "_entityName": "mtSystemDemo.ActionDevicesGroup",
    "_persistentClass": "mtSystemDemo.ActionDevicesGroup, mtSystemDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
    "_interfaces": [
    "NHibernate.Proxy.INHibernateProxy, NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4"
    ],

    
    //Expected
    [
    {
    "Id": 1,
    "DeviceName": "DEV1",
    "DeviceGroup": {
    "Id": 1,
    "GroupProperty": 0,
    "ActionGroupName": "DeviceGroup1",
    "AActionGroups": [

//most likely problem is here
    public void AddNewDevice(ADevice myNewDevice)
    {
    string s = GetAllDeviceData(); //Get right data

    using (var session = _iSessionFactory.OpenSession())
    {
        List<ActionDevicesGroup> localDeviceGroup = session.Query<ActionDevicesGroup>().ToList();
        List<ADevice> userr = session.Query<ADevice>().Where(x => x.DeviceName.Contains(myNewDevice.DeviceName) == true).ToList();
        if (userr.Count == 0)
        {
            localDeviceGroup[1].AddNewDevice(myNewDevice);
            using (var transaction = session.BeginTransaction())
            {
                session.SaveOrUpdate(localDeviceGroup[1]);
                //session.SaveOrUpdate(myNewDevice);
                session.Flush();
                transaction.Commit();
            }
        }
        }
    }
    catch (Exception ex)
    {
    }
    ReadDeviceData();
    string ss = GetAllDeviceData(); //Gives wrong data
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source