Last post Nov 16, 2010 11:54 AM by Absinthesis
Sep 23, 2008 06:51 PM|sjnaughton|LINK
Hi I'm trying to read the Association attribute but at runtime it alway seems to be null.
[Association(Name="Employee_Employee", Storage="_Employees", ThisKey="EmployeeID", OtherKey="ReportsTo")]
I'm trying to access it via:
var ass = pkColumn.Provider.Association
Sep 23, 2008 08:37 PM|sjnaughton|LINK
As it turns out eventhough this is null and I can get it via the model:
var association = MetaModel.Default.
Tables.SingleOrDefault(t => t.Name == "Employees").
Columns.SingleOrDefault(c => c.Name == "Employees").Provider.Association;
What I realy wanted was the AssociationAttribute which I can get this way;
var association = metaChildColumn.Attributes. OfType<System.Data.Linq.Mapping.AssociationAttribute>().FirstOrDefault();
So I sorted myself out yet again sorry... [:D]
P.S. I still think there may be an issue with:
being null, but i don't need it [;)]
Sep 24, 2008 02:25 AM|marcind|LINK
the object available through the Provider property exposes Dynamic Data's abstraction over the different ORM technologies. The Association property of the Provider is an optional property that becomes not null if the column represents a relationship column.
Hope this clarifies any confusion.
Sep 24, 2008 04:17 AM|sjnaughton|LINK
Hi Marcin, I'd worked out what it did but I thought I had an issue, but I was getting and actual FK column not the L2S FK column [:$]
But what I wanted was the L2S FK column column's metadata which I now have via:
var association = metaChildColumn.Attributes.OfType<System.Data.Linq.Mapping.AssociationAttribute>().FirstOrDefault();
So I'm all done [:D] but thanks for the prompt replay anyway, I was up quite late digging it up, I think the old grey cells were a bit sleepy [|-)]
Nov 08, 2009 10:48 AM|sjnaughton|LINK
For future reference here is where you find the same association info for Entity Framework:
Hope this helps
Nov 16, 2010 11:54 AM|Absinthesis|LINK
I was looking at converting your Childgrid field template to EntityFramework. And I am actually on this line of code exactly trying to figure out if the FirstorDefault() is throwing the following
"The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'."