i want use or operator on ints. can use this.
new int[] { 1, 1, 2, 2, 4, 8, 24, 32, 56 }.aggregate((a,b) => | b) it equals 63. however, can't like
db.numbers.select(a => a.number).aggregate((a,b) => | b) it throws exception:
notsupportedexception: linq entities not recognize method 'int32 aggregate[int32](system.collections.generic.ienumerable
1[system.int32], system.func3[system.int32,system.int32,system.int32])' method, , method cannot translated store expression.````
i think because not know function in sql server implements a | b. don't know too.
is there way implement on without aggregating locally?
aggregate not supported linq-to-entities (regardless of function pass in). remember sql set-based, custom aggregations very difficult translate sql.
you can aggregation outside of sql:
db.numbers.select(a => a.number) .asenumerable() // shift ef linq-to-objects .aggregate((a,b) => | b) the main difference entire data set pulled memory rather result of aggregation. if can figure out way aggregation in sql (i can't think of one) may have better performance executing sql statement rather linq query.
Comments
Post a Comment