Hello
I'm trying to create a module with Cristoc's module base and I'm hitting an error where the function CBO.FillColllection is returning an empty object.
I'm using
a Info class
a procedure on the database (returning results)
a DataProvider class (returning results) (as IDataReader)
a Controller class (empty result) (returning Info class)
a onload function calling the controlle
So, my Info class looks like:
using System;
using DotNetNuke.Entities;
namespace Christoc.Modules.NLVerwaltung
{
public class NiederlassungenInfo : BaseEntityInfo
{
public int ID { get; set; }
public string Name { get; set; }
public string Ort { get; set; }
public string Adresse { get; set; }
public float Latitude { get; set; }
public float Longitude { get; set; }
}
}
My DataProvider class:
using System;
using System.Data;
namespace Christoc.Modules.NLVerwaltung.Components
{
public class DataProvider
{
#region Shared/Static Methods
private static readonly DataProvider provider;
static DataProvider()
{
provider = new DataProvider();
}
public static DataProvider Instance()
{
return provider;
}
#endregion
#region Virtual Methods
public virtual IDataReader GetNiederlassungen()
{
return (DotNetNuke.Data.DataProvider.Instance().ExecuteReader("DUV_GetNiederlassungen"));
}
#endregion
}
}
Controller class:
using System.Collections;
using System.Collections.Generic;
using DotNetNuke.Common.Utilities;
using Christoc.Modules.NLVerwaltung.Components;
using System.Data;
namespace Christoc.Modules.NLVerwaltung
{
public class NiederlassungenController
{
public List<NiederlassungenInfo> GetNiederlassungen()
{
return CBO.FillCollection<NiederlassungenInfo>(DataProvider.Instance().GetNiederlassungen());
}
}
}
Call onload:
private readonly NiederlassungenController _NiederlassungenController = new NiederlassungenController();
private void LoadList(Repeater Repeater)
{
List<NiederlassungenInfo> NLs = _NiederlassungenController.GetNiederlassungen();
}
So, now I'm calling _NiederlassungenController.GetNiederlassungen(),
which is calling CBO.FillCollection<NiederlassungenInfo>(DataProvider.Instance().GetNiederlassungen()),
calling DotNetNuke.Data.DataProvider.Instance().ExecuteReader("DUV_GetNiederlassungen").
The last line calls the DB procedure which has a result, so my DataReader is returning a result. (IdataReader)
Next my Controller tries to convert my IDataReader to List<NiederlassungenInfo>.
This one is failing.
The result will be a list with correct resultsize, but every list item will has the default value on all properties, so the result is empty.
The call CBO.FillCollection is comming out of the DotNetNuke.dll, namespace DotNetNuke.Common.Utilities.
If I now create a namespace i.e. DotNetNuke.Common.Utilities2 and copy the whole namespace out of the dll and use the code in my own namespace, now everything is working like expected.
Anyone knows this problem or can help with it?
Greets
Robin