iqueryable

Expose IQueryable Over WCF Service

点点圈 提交于 2019-11-27 05:34:28
I've been learning about IQueryable and lazy loading/deferred execution of queries. Is it possible to expose this functionality over WCF? I'd like to expose a LINQ-to-SQL service that returns an IQueryable which I can then perform additional queries on at the client, and finally execute using a .ToList(). Is OData format applicable at all in this context? If possible, what is the term for this technique and what are some good tutorials I can follow? Thank you. You should check WCF Data Services which will allow you to define Linq query on the client. WCF Data Services are probably the only

IQueryable & Repositories - take 2?

孤者浪人 提交于 2019-11-27 04:56:21
I have to admit I have been carrying the "Repository should not return IQueryable" banner because it is harder to test. I have been influenced by the answers to other questions like this and this . This morning I've been reading ScuttGu's blog about ASP.NET vNext where he details Model Binding using a SelectMethod that seems to rely on IQueryable for paging and sorting. Do you think this will force us to reconsider the role IQueryable plays in repositories? DDD Repository should encapsulate data access technicalities: Definition: A Repository is a mechanism for encapsulating storage, retrieval

.NET Entity Framework - IEnumerable VS. IQueryable

风流意气都作罢 提交于 2019-11-27 03:47:24
问题 Please see this line of code. This is an invocation of a stored procedure, which returns an ObjectResult<long?> . In order to extract the long values I added the Select: dbContext.FindCoursesWithKeywords(keywords).Select(l => l.Value); Based on intellisense this Select returns IEnumerable<long> . I'm not sure whether I read it somewhere or maybe just got used to this assumption - I always thought that when the EF API returns an IEnumerable (and not IQueryable ) then this means that the

ASP.MVC: Repository that reflects IQueryable but not Linq to SQL, DDD How To question

拜拜、爱过 提交于 2019-11-27 01:04:43
I want to create a DDD repository that returns IQueryable Entities that match the Linq to SQL underlying classes, minus any relations. I can easily return Entities minus the relations with a Linq select new {field, field, ... } projection. How do I code the Repository Entity class? How would I return an object from the repository having the repository class not the Linq to SQL class and still fill it with multiple entities from the Linq selection? How would I reference this returned class in my ViewModel? I am very new to this, thus the obvious mistakes. Am I missing the boat and should only

LINQ OrderBy not ordering .. changing nothing .. why?

戏子无情 提交于 2019-11-26 21:46:13
问题 Any idea why the LINQ OrderBy is not working in following code, (have no errors but method does not sort ...) First my own type public class IQLinksView { public int id { get; set; } public int catid { get; set; } public int? viewed {get;set;} public string name {get;set;} public string desc {get;set;} public string url {get;set;} public string pic {get;set;} public string cat {get;set;} } then query : IQueryable<IQLinksView> newView = from links in this.emContext.tbl_otherlinks select new

Differences between IQueryable, List, IEnumerator?

谁都会走 提交于 2019-11-26 17:00:01
I am wondering what the difference between IQueryable, List, IEnumerator is and when I should use each one? For instance when using Linq to SQL I would do something like this: public List<User> GetUsers() { return db.User.where(/* some query here */).ToList(); } Now I am wondering if I should be using IQueryable instead. I am unsure of the advantages of using it over the list. Adam Robinson IQueryable<T> is intended to allow a query provider (for example, an ORM like LINQ to SQL or the Entity Framework) to use the expressions contained in a query to translate the request into another format.

What's the difference between IQueryable and IEnumerable

女生的网名这么多〃 提交于 2019-11-26 16:57:26
I'm confused as to the difference. Being fairly new to .Net, I know I can query IEnumerables using the Linq extensions. So what is this IQueryable and how does it differ? See also What is the difference between IQueryable[T] and IEnumerable[T]? that overlaps with this question. Richard Szalay IEnumerable<T> represents a forward-only cursor of T . .NET 3.5 added extension methods that included the LINQ standard query operators like Where and First , with any operators that require predicates or anonymous functions taking Func<T> . IQueryable<T> implements the same LINQ standard query operators,

Convert IQueryable<> type object to List<T> type?

最后都变了- 提交于 2019-11-26 15:57:45
问题 I have IQueryable<> object. I want to Convert it into List<> with selected columns like new { ID = s.ID, Name = s.Name } . Edited Marc you are absolutely right! but I have only access to FindByAll() Method (because of my architecture). And it gives me whole object in IQueryable<> And I have strict requirement( for creating json object for select tag) to have only list<> type with two fields. 回答1: Then just Select : var list = source.Select(s=>new { ID = s.ID, Name = s.Name }).ToList(); (edit)

To return IQueryable<T> or not return IQueryable<T>

試著忘記壹切 提交于 2019-11-26 14:54:53
I have a repository class that wraps my LINQ to SQL Data Context. The repository class is a business line class that contains all the data tier logic (and caching and such). Here's my v1 of my repo interface. public interface ILocationRepository { IList<Location> FindAll(); IList<Location> FindForState(State state); IList<Location> FindForPostCode(string postCode); } But to handle paging for FindAll, I'm debating whether or not to expose IQueryable<ILocation> instead of IList to simplify the interface for circumstances such as paging. What are the pros and cons to exposing IQueryable from the

IList<T> to IQueryable<T>

混江龙づ霸主 提交于 2019-11-26 14:10:06
问题 I have an List and I'd like to wrap it into an IQueryable. Is this possible? 回答1: List<int> list = new List<int>() { 1, 2, 3, 4, }; IQueryable<int> query = list.AsQueryable(); If you don't see the AsQueryable() method, add a using statement for System.Linq . 回答2: Use the AsQueryable<T>() extension method. 来源: https://stackoverflow.com/questions/73542/ilistt-to-iqueryablet