... it just doesn't work, at all. I've tried for days, with all different combinations of frick'n stuff and it won't budge.
There are certainly people out there who seem to be blogging about breezing through this sort of thing without seeing a glimpse of an issue saying things like "We all know that you can show public properties of extended EF classes by..." and "If you want to extend your data model to show a calculated field, simply..." - not so simple for me - arghghhhhghhhhhghh!!!
So, as per all of the typical examples, my EF partial class looks like this:
[DisplayColumn("Name")]
[MetadataType(typeof(SaleProduct_Metadata))]
public partial class SaleProduct
{
public string Test
{
get
{
return "blah";
}
}
public class SaleProduct_Metadata
{
[ScaffoldColumn(true)]
public string Test;
}
}
My global.asax looks like this:
MetaModel model = new MetaModel();
model.RegisterContext(typeof(Sale.Models.SaleEntities), new ContextConfiguration() { ScaffoldAllTables = true });
routes.Add(new DynamicDataRoute("DD/{table}/{action}.aspx")
{
Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
Model = model
});
And my List.aspx.cs looks like this:
public partial class List : System.Web.UI.Page
{
protected MetaTable table;
protected void Page_Init(object sender, EventArgs e)
{
//DynamicDataManager1.RegisterControl(GridView1, true /*setSelectionFromUrl*/);
table = GridDataSource.GetTable();
DynamicDataManager1.RegisterControl(GridView1, true /*setSelectionFromUrl*/);
GridView1.ColumnsGenerator = new AdvancedFieldGenerator(table, true);
}
protected void Page_Load(object sender, EventArgs e)
{
table = GridDataSource.GetTable();
Title = table.DisplayName;
GridDataSource.Include = table.ForeignKeyColumnsNames;
InsertHyperLink.NavigateUrl = table.GetActionPath(PageAction.Insert);
// Disable various options if the table is readonly
if (table.IsReadOnly)
{
GridView1.Columns[0].Visible = false;
InsertHyperLink.Visible = false;
}
}
protected void OnFilterSelectedIndexChanged(object sender, EventArgs e)
{
GridView1.PageIndex = 0;
}
}
...I'm using a version of Dynamic Data Futures to get functionality like column ordering, better validation, etc, which is working fine. Have made a couple of adjustments to (e.g.) List.aspx.cs (shown above) and have changed the date formatting so as NZ style dates work on my US web-server. Other than that, everything's pretty standard, AFAIK.
My EF Models are housed in a separate assembly and am (obviously) extending some of the Entitys using partial classes. I just want to show two calculated bloody fields, but am having no success at all. I feel like I'm a new programmer bashing my head against a brick wall - none of the old tricks work. Programming shouldn't be this hard :-(
Someone, anyone, please help!!
Bernard.