public void Query_With_ConvertBy() { DB.Prepare(); var cmd = DB.Link.From(x => x.Regions.As(x.Reg)); ConsoleEx.WriteLine("\n> Command: {0}", cmd); Func <Core.IRecord, object> converter = rec => { dynamic row = rec; DataDB.Region reg = new DataDB.Region(); reg.Id = row.Id; reg.Name = (string)rec["Name"]; reg.ParentId = row.Reg.ParentId; // Using the alias return(reg); }; foreach (var obj in cmd.ConvertBy(converter)) { ConsoleEx.WriteLine("\n- {0}", obj); } }
public void Query_With_ConvertBy() { DB.Prepare(); var cmd = DB.Link.From(x => x.Regions.As(x.Reg)); ConsoleEx.WriteLine("\n> Command: {0}", cmd); Func<Core.IRecord, object> converter = rec => { dynamic row = rec; DataDB.Region reg = new DataDB.Region(); reg.Id = row.Id; reg.Name = (string)rec["Name"]; reg.ParentId = row.Reg.ParentId; // Using the alias return reg; }; foreach (var obj in cmd.ConvertBy(converter)) ConsoleEx.WriteLine("\n- {0}", obj); }