/// <summary> /// Fills out a model of type <typeparamref name="T"/> using <c>traverse</c>. <paramref name="db"/> must be open. /// </summary> /// <remarks> /// <para>Note that <c>traverse</c> can be slow, and <c>select</c> may be more appropriate. See /// http://www.orientechnologies.com/docs/last/orientdb.wiki/SQL-Traverse.html#should-i-use-traverse-or-select /// </para> /// <para>Lightweight edges are not followed when populating model properties. Make sure to use "heavyweight" edges with either /// <c>alter property MyEdgeClass.out MANDATORY=true</c> and <c>alter property MyEdgeClass.in MANDATORY=true</c>, or else /// use <c>alter database custom useLightweightEdges=false</c>.</para> /// </remarks> /// <typeparam name="T">The model type. Must extend <see cref="ABaseModel"/>, have a parameterless constructor, and most importantly it must be in the same /// namespace as <see cref="ABaseModel"/>.</typeparam> /// <param name="db">The database to query</param> /// <param name="from">The root RID to traverse.</param> /// <returns>A model representing the record indicated by <paramref name="from"/>.</returns> public static T Traverse <T>(this ODatabase db, ORID from) where T : ABaseModel, new() { // Traverse<T>(from.ToString()) is guaranteed to have 0 or 1 elements return(db.Traverse <T>(from.ToString()).SingleOrDefault()); }