i use entity framework and have the below code:
public class AdvPackageInfo
{
private int PackageId;
private string Caption;
private int Duration;
private int Count;
private bool Enable;
private float Price;
}
AdvertismentAgancyEntities enn = new AdvertismentAgancyEntities();
List<AdvPackageInfo> lst = (from s in enn.Tbl_AdvPackage select new AdvPackageInfo { }).ToList();
repeater1.DataSource = lst;
repeater1.DataBind();
but it works just 1 time and when my page load for the second time it fails in execution and raise NullReferenceException...!!
according to this pag :
http://connect.microsoft.com/VisualStudio/feedback/details/663200/linq-to-entities-throws-nullreferenceexception-when-the-output-attribute-set-is-empty
it's dot net framework problem.
i try this code too :
var q = (from s in enn.AdvPackage select s).toList();
but it doesn't work either.
is there any better way to make a linq select to a list????