//[Test] public void SelectAllTitlesFull2() { using (var db = new MusicDB()) { var query2 = new FullSqlQuery(db); var titles = query2.SelectAll <Title>(); var title = (Title)query2.SelectByKey(typeof(Title), 137653); } }
//[Test] public void SelectAllArtistsIgnoreLazyLoading() { using (var db = new MusicDB()) { var query2 = new FullSqlQuery(db, true); //loading is automatic var artist2 = (Artist2)query2.SelectByKey(typeof(Artist2), 2643); var titles2 = artist2.Titles; var query = new FullSqlQuery(db); // Dont ignore lazyloading var artist = (Artist2)query.SelectByKey(typeof(Artist2), 2643); var titles = artist.Titles; Assert.AreEqual(titles2.Count, titles.Count); } }
private object LoadLazy(IMapper mapper, object proxy, Type parentType) { var lazyMapper = (ILazyMapper)mapper; object key = lazyMapper.ParentKeyGetter(proxy); var fullSqlQuery = new FullSqlQuery(_db, true); object parentLoadFull = fullSqlQuery.SelectByKey(parentType, key); if (parentLoadFull == null) { object value = Activator.CreateInstance(mapper is CollectionFullObjectMapper ? (mapper as CollectionFullObjectMapper).PropertyCollectionType : mapper.PropertyType); return(value); } var objectMapper = (IObjectMapper)mapper; return(objectMapper.Getter(parentLoadFull)); }