I have following two Queries on Same Table and need to merge it.
var Prod = this.UnitOfWork.myRepository.GetData();
var PreProd = this.UnitOfWork.myRepository.GetData();
var Merge = Prod.Union(PreProd);
But when i check results of Merge it doesn't show Union but shows following message
Message: This method supports the LINQ to Query Result Union not working Entities infrastructure and is not intended to be used directly from your code
How this can be accomplished.
You can use .AsEnumerable() to convert IQueryable to IEnumerable firstly.
var Prod = this.UnitOfWork.myRepository.GetData().AsEnumerable();
var PreProd = this.UnitOfWork.myRepository.GetData().AsEnumerable();
var Merge = Prod.Union(PreProd);
LINQ to EF supported Union :
IQueryable<TSource> Union<TSource>(
this IQueryable<TSource> source1,
IEnumerable<TSource> source2
)
so try:
var Prod = this.UnitOfWork.myRepository.GetData();
var PreProd = this.UnitOfWork.myRepository.GetData();
var Merge = Prod.Union(PreProd.AsEnumerable());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.