iqueryable

How to construct IQueryable query using Linq when I just need count without reading all documents in Document-Db database?

孤人 提交于 2019-12-24 08:34:40
问题 I need the number of documents stored in a collection in my Azure Cosmos Db database. How can I get the count using LINQ query on the IQueryable object? docDbClient.CreateDocumentQuery<TResult>().Count() If I do above, I am unable to follow it up with .AsDocumentQuery() method. 回答1: This is my async implementation (use Count, for the sync version): var count = await DocumentClient. CreateDocumentQuery<T>(CreateCollectionUri(), CreateFeedOptions()). Where(predicate). CountAsync(); where

How to perform a LINQ join on IQueryable<T> in odata controller

╄→гoц情女王★ 提交于 2019-12-24 07:48:43
问题 I have a WebAPI method which uses the OData Query Options to return data to the client. The entity has cityid and I want cityname from another entity using joins. I have tried using below Api method, which is incomplete. Entity1:- public partial class UU_DeliveryCharges { public int DeliveryChargeId { get; set; } public Nullable<int> CityId { get; set; } public Nullable<int> VehicleTypeId { get; set; } public Nullable<decimal> MileRate { get; set; } public Nullable<decimal> FlatRate { get;

How can I implement Query Interception in a LINQ to Entities query? (c#)

北城以北 提交于 2019-12-24 04:53:54
问题 I'm trying to implement encrypted columns in EF4 and using the CTP5 features to allow simple use of POCO's to query the database. Sorry that this is a lot of words, but I hope the below gives enough to explain the need and the problem! So, bit of background, and my progress so far: The intention is that if you query the tables without using our DAL then the data is rubbish, but I don't want the developers to worry about if/when/how the data is encrypted. For simplicity, at this stage I'm

Why 'Lambda' is not supported in my LINQ to Entities syntax [duplicate]

↘锁芯ラ 提交于 2019-12-24 02:43:05
问题 This question already has answers here : “The LINQ expression node type 'Invoke' is not supported in LINQ to Entities” - stumped! (4 answers) Closed 6 years ago . I get an error when I try to run the following query in LINQ to Entities: public IEnumerable TestOne2() { var query = this.Context.CmnAddressCities .Join(this.Context.CmnAddressStates, p => p.StateID, q => q.StateID, (p, q) => SelectSearchColumns) .ToList(); return query; } public Expression<Func<CmnAddressCity,CmnAddressState,

Why 'Lambda' is not supported in my LINQ to Entities syntax [duplicate]

穿精又带淫゛_ 提交于 2019-12-24 02:43:04
问题 This question already has answers here : “The LINQ expression node type 'Invoke' is not supported in LINQ to Entities” - stumped! (4 answers) Closed 6 years ago . I get an error when I try to run the following query in LINQ to Entities: public IEnumerable TestOne2() { var query = this.Context.CmnAddressCities .Join(this.Context.CmnAddressStates, p => p.StateID, q => q.StateID, (p, q) => SelectSearchColumns) .ToList(); return query; } public Expression<Func<CmnAddressCity,CmnAddressState,

Why Does This Queryable.Where Call Change the Queryable's Type Parameter?

梦想的初衷 提交于 2019-12-24 02:26:06
问题 Code to Reproduce Issue I ran into a situation where an IQueryable.Where<TSource> call was returning an IQueryable<TOther> where TOther != TSource . I put together some sample code to reproduce it: using System; using System.Collections.Generic; using System.Linq; namespace IQueryableWhereTypeChange { class Program { static void Main( string[] args ) { var ints = new List<ChildQueryElement>(); for( int i = 0; i < 10; i++ ) { ints.Add( new ChildQueryElement() { Num = i, Value = i.ToString() }

Dynamic LINQ, Select function, works on Enumerable, but not Queryable

一笑奈何 提交于 2019-12-23 20:15:59
问题 I have been fiddling with dynamic LINQ for some time now, but I have yet to learn its secrets. I have an expression that I want to parse that looks like this: "document.LineItems.Select(i => i.Credit).Sum();" During parsing of this I reach a point where I need to call a Select function on LineItems Collection. I am using factory method of Expression.Call: Expression.Call( typeof(Queryable), "Select", new Type[] { typeof(LineItem), typeof(decimal?) }, expr, Expression.Lambda(expression, new

Customizing IQueryable<T>

五迷三道 提交于 2019-12-23 17:08:52
问题 I'm trying to customize entities of my application to make them have a property referencing the DataContext that loaded them. I think the best way is to somehow create a class that implements the IQueryable and set the entity datacontext property in its GetEnumerator method. My question is, how can I use the Provider and Expression used by Linq to SQL in my implementation of IQueryable so that I don't have to implement them myself? BTW: For my scenario, is there another way? Take a look at

Cannot implicitly convert type 'Program.Data.View' TO System.linq.iqueryable<Program.Data.View>.

a 夏天 提交于 2019-12-23 13:04:07
问题 Goal/Problem: I am trying to use the First or FirstOrDefault to only return 1 result from the Database. I'm getting the following error: Cannot implicitly convert type 'Program.Data.view' to System.Linq.Iqueryable An explicit conversion exists (are you missing a cast) What I've tried: After looking through documentation and many SO articles, I tried different ways of casting, including the code below. Articles such as Cannot implicitly convert type 'System.Linq.IQueryable<>to . An explicit

Missing QueryableExtensions in EF 6

泄露秘密 提交于 2019-12-23 11:22:30
问题 I can't call the new QueryableExtensions ( ToListAsync , ForEachAsync ,...) provided with EntityFramework 6. But i can call others ( Include , Intersect ). I've a reference to System.Data.Entity . So apparently, i've an older version of System.Data.Entity , with the latest version of EntityFramework. Is it possible? My code does not compile and I cannot see the ForEachAsync method in the object browser. I'm working with Visual Studio 2013, .Net 4.5, EntityFramework 6.1.3, Wpf. Edit Entity