iqueryable

Converting IQueryable<object> results to comma delimited string

Hi, I have a LINQ query that returns all absences for an employee. The first part of the linq statement gets a basic list of the employees details, but I also return an IQueryable list of illnesses related to that absence. I'd like to somehow convert that IQueryable list to a comma delimited list of Illnesses. Currently I use (majorl...

Determine the position of an element in an IQueryable

I have a IQueryable which is ordered by some condition. Now I want to know the position of a particular element in that IQueryable. Is there a linq expression to get that. Say for example there are 10 elements in the IQueryable and the 6th element matches a condition, I want to get the number 6. ...

sorting of an Iqueryable

I have an IQueryable with duplicate entries and I want to sort this IQueryable by the count of occurrences. ...

IQueryable into a hierarchy

I currently have an IQueryable of Questions. In my Question object I have and "id" and a "parentId" which can be used to create a hierarchy. Currently, I bind a RadTreeView to the IQueryable of Questions and the RadTreeView takes care of creating the hierarchy because I define the dataId and dataParentId for the TreeView in the markup....

The order of elements vary in an Iquerable, every time I query with the same condition

I am working on a ASP.NET MVC application where we have to write our own code for paging. And I see elements getting repeated on different pages. This is happening because the order of elements in the Iquerable varies randomly and one have to query the database for each page. I solved this problem by ordering the elements by date of cre...

C# IQueryable - will add diferent dimension?

Just I am maintaining a project.It has been written in C# 3.0.Some Implementations return collection as IQueryable. like List<BookData> data = new List<BookData>(); ... data.Add(new BookData { ID = "P001", BookTitle = "C# in Depth" }); data.Add(new BookData { ID = "P002", BookTitle = "F# in Depth" }); public IQueryable G...

What's the difference between these two LINQtoSQL statements?

These two statements look the same logically to me, but they're resulting in different SQL being generated: #1 var people = _DB.People.Where(p => p.Status == MyPersonEnum.STUDENT.ToString()); var ids = people.Select(p => p.Id); var cars = _DB.Cars.Where(c => ids.Contains(c.PersonId)); #2 string s = MyPersonEnum.STUDENT.ToString(); va...

Is an IQueryable a query or just an object which can be queried?

I'm kinda confused what the IQueryable interface actually represents. The MSDN documentation for IQueryable says: "Provides functionality to evaluate queries against a specific data source." The documentation for IQueryProvider says: "Defines methods to create and execute queries that are described by an IQueryable object." The name a...

LINQ and SQL Server performance tuning the SQL Server 2008 database best practice?

My question is what is best practice to optimize performance using LINQ for SQL And performance is response time out in the user interface. Right now I have some sales data in a SQL Server 2008 database and I display this data (MAT, yearly, in different segments, growth in segment, percent of market growth ,,,,) in charts in a ASP.NET a...

Linq Query Question

I have this code that returns a caseID from an Alleged Perpetrator table. This table also has a column "LastName". I want to search on caseID and return LastName but I don't know how to code it. I've been on the microsoft site looking for LINQ to SQL examples but still can't figure it out. Any help would be greatly appreciated! Ken pub...

Getting mapped rows from IQueryable<ForeignKey> in Linq2Sql

The situation is: a webpage displays a listing of Gatherings to a logged-in user. Among this Queryable group might be Gatherings that the user is subscribed to but has not yet viewed until loading this page. Now that the Gatherings have been viewed by this user, I want to mark them as such. I can get this to work by using ToList() and C...

IQueryable<T> first free spot

What's the most efficient way to get a first free spot from sorted query returning int collection ? eg.: {1,2,3,4,6} | result.: 5 At the moment I am using foreach and counter that compares current value from sorted quety.ToList() which takes about 600ms on 100 000 records. ...

Linq conversion

I am using the following code to return an IList: public IList<string> FindCodesByCountry(string country) { var query = from q in session.Linq<Store>() where q.Country == country orderby q.Code select new {q.Code}; return (IList<stri...

IQueryable to DataSet

I have seen numerous methods and tricks around the net today. What i need is convert my Linq to SQL queries (IQueryable results) into a DataSet for reporting purposes. Reporting tool is XtraReports from DevExpress. A promising solution i found in another post is modelshredder. I am still concern though about the whole object graph, what...

IQueryable contains any of string array

I am not shore why IQuerable limits me when I try to search database for data containing string from an array. objectFactory.Resolve<IUserDao>().Query. Where(t => (spltedInput.Any(val=> t.LastName.Contains(val)) || spltedInput.Any(val=> t.Name.Contains(val))) && t.MasterCompany.I...

How to access data into IQueryable??

I have IQueryable object and I need to take the data inside the IQueryable to put it into Textboxs controls. Is this possible? I try something like: public void setdata (IQueryable mydata) { textbox1.text = mydata.???? } Update: I'm doing this: public IQueryable getData(String tableName, Hashtable myparams) { decimal ...

LINQ to Entites/IQueryable: Sorting on multiple fields

I have the following that I'd like to sort: IQueryable<Map> list; list = from item in ctx.MAP .Include("C") .Include("L") .Include("L.DP") select item; return list.OrderBy(m=>(m.L.DP.Name + m.L.Code)); This works, but it sorts alphabetically - so 12 comes before 9. (Assume Code is a num...

How to retrieve ordering information from IQueryable object?

Let's say, I have an instance of IQueryable. How can I found out by which parameters it was ordered? Here is how OrderBy() method looks like (as a reference): public static IOrderedQueryable<T> OrderBy<T, TKey>( this IQueryable<T> source, Expression<Func<T, TKey>> keySelector) { return (IOrderedQueryable<T>)source.Provider.Crea...

ASP MVC: Should services return IQueryable's?

What do you think? should your DAO return an IQueryable to use it in your controllers? Thanks in advance ...

Linq to Entities: How do I pass an IQueryable to a Method

I am really baffled on this one. I am trying to pass my posts vaiable to a method. How do I go about doing this: var posts = from p in context.post where (p.post_isdeleted == false && (object.Equals(p.post_parentid, null)) select new { p.post_date, p.post_id, ...