/* * /// <summary> * /// Shortcut for getting an EdgeObject reference from fields during runtime. * /// </summary> * public static T GetEdgeObject<T>(this MappingContext<T> context, string fieldGK, string fieldTypeID, string fieldClrType) * where T : EdgeObject * { * if (context.GetField<object>(fieldGK) == null) * return null; * * T obj = context.Cache.GetOrCreate( * Type.GetType(context.GetField<string>(fieldClrType)), * EdgeObject.Identites.Default, * EdgeObject.Identites.Default.NewIdentity(context.GetField<long>(fieldGK)) * ); * * if (obj.EdgeType == null) * obj.EdgeType = context.Cache.GetOrCreate<EdgeType>( * EdgeType.Identities.Default, * EdgeType.Identities.Default.NewIdentity(context.GetField(fieldTypeID)) * ); * * return obj; * } */ /* * public static Mapping<T> MapEdgeField<T, V>(this Mapping<T> mapping, EntityProperty<T, V> property) * where T : EdgeObject * { * return mapping * .Map<V>(property, prop => prop * .Set(context => * { * EdgeField field = context.Cache.Get<EdgeField>(EdgeField.Identities.Default, property.Name); * return context.GetField<V>(String.Format("{0}_Field{1}", field.ColumnPrefix, field.ColumnIndex)); * }) * ); * } */ /// <summary> /// Shortcut for ensuring ID is not -1. /// </summary> public static void NullIf <V>(this MappingContext context, string idField, Func <V, bool> condition) { if (condition(context.GetField <V>(idField))) { context.Target = null; context.Break(); } }