linq - Iterating tables in a context and the properties of those tables -
I repeat the tables of reference and then in order to load all the columns eagerly in the context of the properties of those tables . I have received some help through some other question, but I think how to iterate the column properties of the actual table.
Last Job Code:
Public Static Zero DisableLazyLoading (This DataContext Reference) {DataLoadOptions Option = New DataLoadOptions (); Var contextableables = reference.gettype (). GetProperties (). Where (n = & gt; nproperty type.name == "table` 1"); Forward (table in context reference) {var tabletop = context tab.gate value (reference, empty) .getType (). GetGenericArguments () [0]; Var Table Properties = tableType.GetProperties (). Where (n = & gt; n.PropertyType.Name! = "EntitySet`1"); Foreign exchange (form table in table table) {parameter Exercise Parax = Expression. Parameter (Table Type, "S"); Expression expr = Expression.Property (paramExp, tableProperty.Name); Options.LoadWith (expression. Lambda (expr, paramExp)); }} Context.LoadOptions = Option; }
You are only receiving ProperInfo
s. You need to get to from PropertyInfo
s:
var tablePropertInfos = context.GetType (). GetProperties (). N = & gt; N.PropertyType.Name == "Table1"); Foreign currency (TablePropertyInf in Table Table Property Infone) {// Receive actual table table table = tablePropertyInfo.GetValue (Reference, blank); ///> Once you receive the PropertyInfo
class, you get the GetValue
method.
Comments
Post a Comment