44using System . Runtime . Serialization ;
55using SolrNet . Attributes ;
66using SolrNet . Commands . Parameters ;
7+ using SolrNet . Exceptions ;
78using Xunit ;
89
910namespace SolrNet . Linq . IntegrationTests
@@ -38,6 +39,25 @@ public void AnonymousClass()
3839 Assert . NotNull ( t1 ) ;
3940 }
4041
42+ [ Fact ]
43+ public void MultipleSelects ( )
44+ {
45+ var t1 = Product . SolrOperations . Value . AsQueryable ( lo => lo . SetupQueryOptions = qo =>
46+ {
47+ Assert . Equal ( 1 , qo . Fields . Count ) ;
48+ Assert . Equal ( 3 , qo . FilterQueries . Count ) ;
49+ Assert . Equal ( "Id:id" , qo . Fields . ElementAt ( 0 ) ) ;
50+ } ) . Where ( p => p . Id != null )
51+ . Select ( p => new { p . Id , p . Price , p . Categories , Qwe = Math . Pow ( 2 , 2 ) } )
52+ . Where ( arg => arg . Categories . Any ( s => s == "electronics" ) )
53+ . OrderBy ( arg => arg . Id )
54+ . Select ( arg => new { arg . Id } )
55+ . FirstOrDefault ( arg2 => arg2 . Id != null ) ;
56+
57+ Assert . NotNull ( t1 ) ;
58+ }
59+
60+
4161 [ Fact ]
4262 public void Product2 ( )
4363 {
@@ -53,7 +73,9 @@ public void Product2()
5373 Assert . Equal ( "id" , qo . OrderBy . ElementAt ( 0 ) . FieldName ) ;
5474 Assert . Equal ( "pow(2,2)" , qo . OrderBy . ElementAt ( 1 ) . FieldName ) ;
5575 Assert . Equal ( "pow(2,3)" , qo . OrderBy . ElementAt ( 2 ) . FieldName ) ;
56-
76+
77+ Assert . Equal ( 2 , qo . FilterQueries . Count ) ;
78+
5779 } ) . Where ( p => p . Id != null )
5880 . Select ( p => new Product2 { Id = p . Id , Price = p . Price , Categories = p . Categories , Qwe = Math . Pow ( 2 , 2 ) } )
5981 . Where ( arg => arg . Categories . Any ( s => s == "electronics" ) )
@@ -78,5 +100,28 @@ public void Product2()
78100 Assert . Single ( t3 ) ;
79101 Assert . Equal ( t1 . Id , t3 . Single ( ) . Id ) ;
80102 }
103+
104+ [ Fact ]
105+ public void Product2WithMemberProduct ( )
106+ {
107+ Assert . Throws < SolrConnectionException > ( ( ) => Product . SolrOperations . Value . AsQueryable ( lo => lo . SetupQueryOptions = qo =>
108+ {
109+ Assert . Equal ( 4 , qo . Fields . Count ) ;
110+ Assert . Equal ( "Price:sum(price,1)" , qo . Fields . ElementAt ( 0 ) ) ;
111+ Assert . Equal ( "Qwe:pow(2,2)" , qo . Fields . ElementAt ( 1 ) ) ;
112+ Assert . Equal ( "Id:id" , qo . Fields . ElementAt ( 2 ) ) ;
113+ Assert . Equal ( "Categories:cat" , qo . Fields . ElementAt ( 3 ) ) ;
114+
115+ Assert . Equal ( 3 , qo . OrderBy . Count ) ;
116+ Assert . Equal ( "id" , qo . OrderBy . ElementAt ( 0 ) . FieldName ) ;
117+ Assert . Equal ( "sum(price,1)" , qo . OrderBy . ElementAt ( 1 ) . FieldName ) ;
118+ Assert . Equal ( "pow(2,3)" , qo . OrderBy . ElementAt ( 2 ) . FieldName ) ;
119+ } ) . Where ( p => p . Id != null )
120+ . Select ( p =>
121+ new Product2 { Id = p . Id , Price = p . Price + 1 , Categories = p . Categories , Qwe = Math . Pow ( 2 , 2 ) } )
122+ . Where ( arg => arg . Categories . Any ( s => s == "electronics" ) )
123+ . OrderBy ( arg => arg . Id ) . ThenBy ( arg => arg . Price ) . ThenBy ( arg => Math . Pow ( 2 , 3 ) )
124+ . FirstOrDefault ( ) ) ;
125+ }
81126 }
82127}
0 commit comments