reflection - How to determine lazy-loaded properties at runtime on a linq table? -
I am running on the properties of various mapped tables in my code and it is necessary to know that every asset is lazy. Whether it's loaded or not? I've found that the frequency variable used for storage, which is the property on the storage
attribute, will be System.Data.Linq.Link
.
Is this a way that I can take advantage of these two facts at the runtime to solve this problem?
Code:
Public Zero LazyLoad (Type Table Type) {foreach (Tablet on TableType.GetGenericArguments () [0] .GetProperties ()) {If (/ Bad shipment has been done / /) {// The real work is here ... console WriteLine (prop.Name); }}}
Mapping looks like this:
public partial class address {private system.data.ink.ink.link < String & gt; _city; [Column (storage = "_ city", dbipp = "...")] get public string city {{* * * *}} {/ * ... *}}}
/ Ex>
You are almost there, just a teaspoon of medication filled with reflection helps; -)
Private Stable Bull ISLAG Loaded Property (PropertyInfo Properties) {var column = property.GetCustomAttributes (true, ColumnAttribute) [0] [0] As a column attribute; Var field = property.DeclaringType.GetField (column.Storage, BindingFlags.Instance | BindingFlags.NonPublic); If (! Field.FieldType.IsGenericType) {return false; } Return field.FildTypeGadgetSystem Definition () == Typef (link
Comments
Post a Comment