public void MetaNamedType() { var dic = DynamicQueryCore.QueryMetadata(Database.Query <NoteWithDateEntity>().Select(a => new Bla { ToStr = a.ToString(), Length = a.ToString().Length })); Assert.IsType <CleanMeta>(dic["ToStr"]); Assert.IsType <DirtyMeta>(dic["Length"]); }
public AutoDynamicQueryCore(IQueryable <T> query) { this.Query = query; metas = DynamicQueryCore.QueryMetadata(Query).ThrowIfNull("Query should be an anoynmous type"); StaticColumns = MemberEntryFactory.GenerateList <T>(MemberOptions.Properties | MemberOptions.Fields) .Select((e, i) => new ColumnDescriptionFactory(i, e.MemberInfo, metas[e.MemberInfo.Name])).ToArray(); }
public void MetaAnonymousType() { var dic = DynamicQueryCore.QueryMetadata(Database.Query <NoteWithDateEntity>().Select(a => new { a.Target, a.Text, a.ToString().Length, Sum = a.ToString() + a.ToString() })); Assert.IsType <CleanMeta>(dic["Target"]); Assert.IsType <CleanMeta>(dic["Text"]); Assert.IsType <DirtyMeta>(dic["Length"]); Assert.IsType <DirtyMeta>(dic["Sum"]); }
public void MetaConditional() { var dic = DynamicQueryCore.QueryMetadata( from a in Database.Query <AlbumEntity>() select new { Author = a.Id > 1 ? (ArtistEntity)a.Author : (IAuthorEntity)(BandEntity)a.Author } ); DirtyMeta meta = (DirtyMeta)dic["Author"]; Assert.Equal(meta.Implementations, Implementations.By(typeof(ArtistEntity), typeof(BandEntity))); }
public void MetaCoalesce() { var dic = DynamicQueryCore.QueryMetadata( from a in Database.Query <AlbumEntity>() select new { Author = (ArtistEntity?)a.Author ?? (IAuthorEntity?)(BandEntity?)a.Author } ) !; DirtyMeta meta = (DirtyMeta)dic["Author"] !; Assert.Equal(meta.Implementations, Implementations.By(typeof(ArtistEntity), typeof(BandEntity))); }
public void MetaComplexGroup() { var dic = DynamicQueryCore.QueryMetadata( from a in Database.Query <AlbumEntity>() group a by a.Label into g select new { g.Key, Num = g.Count() }); Assert.IsType <CleanMeta>(dic["Key"]); Assert.IsType <DirtyMeta>(dic["Num"]); Assert.True(((DirtyMeta)dic["Num"]).CleanMetas.Count == 0); }
public void MetaComplexJoinGroup() { var dic = DynamicQueryCore.QueryMetadata( from l in Database.Query <LabelEntity>() join a in Database.Query <AlbumEntity>() on l equals a.Label into g select new { l.Name, Num = g.Count() }); Assert.IsType <CleanMeta>(dic["Name"]); Assert.IsType <DirtyMeta>(dic["Num"]); Assert.True(((DirtyMeta)dic["Num"]).CleanMetas.Count == 0); }
public void MetaSelectMany() { var dic = DynamicQueryCore.QueryMetadata( from a in Database.Query <AlbumEntity>() from s in a.Songs select new { a.Name, Song = s.Name } ); Assert.IsType <CleanMeta>(dic["Name"]); Assert.IsType <CleanMeta>(dic["Song"]); Assert.Equal(((CleanMeta)dic["Song"]).PropertyRoutes[0].ToString(), "(Album).Songs/Name"); }
public void MetaSelectMany() { var dic = DynamicQueryCore.QueryMetadata( from a in Database.Query <AlbumEntity>() from s in a.Songs select new { a.Name, Song = s.Name } ); Assert.IsInstanceOfType(dic["Name"], typeof(CleanMeta)); Assert.IsInstanceOfType(dic["Song"], typeof(CleanMeta)); Assert.IsNotNull(((CleanMeta)dic["Song"]).PropertyRoutes[0].ToString(), "(AlbumEntity).Songs/Name"); }
public void MetaComplexJoin() { var dic = DynamicQueryCore.QueryMetadata( from l in Database.Query <LabelEntity>() join a in Database.Query <AlbumEntity>() on l equals a.Label select new { Label = l.Name, Name = a.Name, Sum = l.Name.Length + a.Name }); Assert.IsInstanceOfType(dic["Label"], typeof(CleanMeta)); Assert.IsInstanceOfType(dic["Name"], typeof(CleanMeta)); Assert.IsInstanceOfType(dic["Sum"], typeof(DirtyMeta)); Assert.AreEqual(((DirtyMeta)dic["Sum"]).CleanMetas.Select(cm => cm.PropertyRoutes[0].ToString()).OrderBy().ToString(","), "(Album).Name,(Label).Name"); }
public void MetaComplexJoin() { var dic = DynamicQueryCore.QueryMetadata( from l in Database.Query <LabelEntity>() join a in Database.Query <AlbumEntity>() on l equals a.Label select new { Label = l.Name, Name = a.Name, Sum = l.Name.Length + a.Name }); Assert.IsType <CleanMeta>(dic["Label"]); Assert.IsType <CleanMeta>(dic["Name"]); Assert.IsType <DirtyMeta>(dic["Sum"]); var metas = ((DirtyMeta)dic["Sum"]).CleanMetas; Assert.Equal(metas.SelectMany(cm => cm.PropertyRoutes).Distinct().ToString(","), "(Album).Name,(Label).Name"); }
public void MetaRawEntity() { var dic = DynamicQueryCore.QueryMetadata(Database.Query <NoteWithDateEntity>()); Assert.NotNull(dic); }
public void MetaNoMetadata() { Assert.Null(DynamicQueryCore.QueryMetadata(Database.Query <NoteWithDateEntity>().Select(a => a.Target))); }