protected new void PopulateListControl(ListControl listControl)
{
var query = Column.Table.GetQuery();
// row
var entityParam = Expression.Parameter(Column.Table.EntityType, "row");
// row => row.DataSourceID
var columnLambda = Expression.Lambda(Expression.Property(entityParam, Column.EntityTypeProperty), entityParam);
// Items.Select(row => row.DataSourceID)
var selectCall = Expression.Call(typeof(Queryable), "Select", new Type[] { query.ElementType, columnLambda.Body.Type }, query.Expression, columnLambda);
// Items.Select(row => row.DataSourceID).Distinct
var distinctCall = Expression.Call(typeof(Queryable), "Distinct", new Type[] { Column.EntityTypeProperty.PropertyType }, selectCall);
var result = query.Provider.CreateQuery(distinctCall);
Having used the code from here to populate my dropdown list I find that only values already in the parent table are being displayed in the select list. I am new to "Expressions" how is it possible to unlink it from the parent table and display all values.
I imagine it's trivial but , as i say, I'm a bear of little brain.
using (var db = new WW1researchDataContext())
{
var result = db.GetTable(this.Column.Provider.ColumnType);
Hi,
Thank you for replying, I saw it's been a while since you were on this so I am most grateful for you looking at the post.
Above was the slightly more native way of doing it I discovered, unfortunately the distinct call does what it says on the tin and the link to the parent occurs elsewhere. I imagine there is something to be done with Column.Table.Provider on the GetQuery
front. Unfortunately the lambda bits look like wizardry to me, I haven't been able to decrypt it!
None
0 Points
9 Posts
ForeignKey_Edit Populating the DropDown with all available values
Aug 11, 2014 07:18 AM|domh|LINK
http://forums.asp.net/t/1673340.aspx?Override+PopulateListControl+in+ForeignKey_Edit+field+template
Having used the code from here to populate my dropdown list I find that only values already in the parent table are being displayed in the select list. I am new to "Expressions" how is it possible to unlink it from the parent table and display all values. I imagine it's trivial but , as i say, I'm a bear of little brain.
DynamicData PopulateListControl foreignKeyEdit
All-Star
17916 Points
5681 Posts
MVP
Re: ForeignKey_Edit Populating the DropDown with all available values
Aug 11, 2014 09:00 AM|sjnaughton|LINK
Hi domh, that could be the distinct just omit that and use the CreateQuery using the SelctCall :)
DynamicData PopulateListControl foreignKeyEdit
Always seeking an elegant solution.
None
0 Points
9 Posts
Re: ForeignKey_Edit Populating the DropDown with all available values
Aug 11, 2014 12:18 PM|domh|LINK
Hi,
Thank you for replying, I saw it's been a while since you were on this so I am most grateful for you looking at the post.
Above was the slightly more native way of doing it I discovered, unfortunately the distinct call does what it says on the tin and the link to the parent occurs elsewhere. I imagine there is something to be done with Column.Table.Provider on the GetQuery front. Unfortunately the lambda bits look like wizardry to me, I haven't been able to decrypt it!
Dom
DynamicData PopulateListControl foreignKeyEdit
All-Star
17916 Points
5681 Posts
MVP
Re: ForeignKey_Edit Populating the DropDown with all available values
Aug 11, 2014 12:23 PM|sjnaughton|LINK
Email me direct and we can discuss what you are trying to achieve :)
DynamicData PopulateListControl foreignKeyEdit
Always seeking an elegant solution.