linq

Reactive Extensions for Java

Is there any equivalent of Reactive Extensions (.NET) for Java? About Rx (Reactive Extensions) Rx is a library for composing asynchronous and event-based programs using observable collections. I am aware of rule engines such as Drools from JBOSS, but is there some other way that is closer to the Microsoft .NET approach? ...

Storing object as a column in LINQ

Hello, i have some class which constructs itself from string, like this: CurrencyVector v = new CurrencyVector("10 WMR / 20 WMZ"); It's actually a class which holds multiple currency values, but it does not matter much. I need to change type of column in my LINQ table (in vs 2010 designer) from String to that class, CurrencyVector. ...

ASP.NET MVC How to convert ModelState errors to json

How do you get a list of all ModelState error messages? I found this code to get all the keys: ( http://stackoverflow.com/questions/888521/returning-a-list-of-keys-with-modelstate-errors) var errorKeys = (from item in ModelState where item.Value.Errors.Any() select item.Key).ToList(); But how would I get the error me...

Accessing Linq data in telerik grid ItemCreated method

Not sure if the title of this question makes sense, but here's my problem: I have a telerik grid bound to a Linq data object, however, I limit the fields returned: <IQueryable>filter = data.Select(x => new {x.ID, x.Name, x.Age}); I would like to access these fields in the ItemCreated method of the grid: protected void rgPeople_ItemC...

Linq to XML: create an anonymous object with element attributes and values

I'm new to Linq and I'm trying to query a XML document to find a list of account managers for a particular user. (I realize it might make more sense to put this in a database or something else, but this scenario calls for a XML document). <user emailAddress='[email protected]'> <accountManager department='Customer Service' title='Ma...

How to upload excel files to database using linq?

My team working in asp.net projects Here we have to upload Excel contents to Database We are using linq Please help to do the same ...

select width entity framework and linq

hi have 2 table missions and missiondays with a relationship 1..n I want select all missions that has all missiondays with an attribute called "visible" = true I've tried with: db.TDP_Missioni.Include("TDP_MissioniDestinazioni").where(p => p.TDP_MissioniDestinazioni.visible == true) But there is an error. Indeed from p.TDP_Mission...

Generic List to EntitySet Conversion

How do I Convert a System.Collections.Generic.List<T> to a System.Data.Linq.EntitySet<T> ? ...

Extend SubSonic's IQueryable Structure (via LINQ?)

I'm working on a project that groups data by a "customer id". When the user logs in, they're limited to that customer and that customer only. I'm working with SubSonic3, and what I've got looks something like this: public IEnumerable<Models.Foo> FindFoo(int userID, string searchText, int pageIndex, int pageSize) { return from item ...

How to grab location information in the XML using linq?

My xml looks like: <kml xmlns="http://earth.google.com/kml/2.0"&gt; <Response> <name>90210</name> <Status> <code>200</code> <request>geocode</request> </Status> <Placemark id="p1"> <address>Beverly Hills, CA 90210, USA</address> <AddressDetails Accuracy="5" xmlns="urn:oasis:name...

Linq query with a Conditional WHERE Clause

Hi All I am new to LINQ so apologises upfront I have the following Linq query :- var OrdersByBranches = from a in AllOrders join b in AllBranchKeys on a.BranchKey equals b.BranchKey orderby a.Date group a by new { a.Date, a.paymentMethod } into BranchOrderGrouped select new { BranchOrderGroup...

Solving Combinatory Problems with LINQ /.NET4

I saw this article pop-up in my MSDN RSS feed, and after reading through it, and the sourced article here I began to wonder about the solution. The rules are simple: Find a number consisting of 9 digits in which each of the digits from 1 to 9 appears only once. This number must also satisfy these divisibility requirements: The numbe...

How to use LINQ to query list of strings that do not contain substring entries from another list

string[] candidates = new string[] { "Luke_jedi", "Force_unknown", "Vader_jedi" , "Emperor_human", "r2d2_robot" }; string[] disregard = new string[] {"_robot", "_jedi"}; //find those that aren't jedi or robots. var nonJedi = candidates.Where(c=> c.??? //likely using EndsWith() and Any() ); How wo...

C# Linq - Cannot implicitly convert IEnumerable<string> to List<string>

I have a List defined like this : public List<string> AttachmentURLS; I am adding items to the list like this: instruction.AttachmentURLS = curItem.Attributes["ows_Attachments"].Value.Split(';').ToList().Where(Attachment => !String.IsNullOrEmpty(Attachment)); But I am getting this error: Cannot implicitly convert IEnumerable to Lis...

How to Loop through LINQ results (VB.NET)

I've got some code to try and loop through LINQ results, but it doesn't seem to be working. HERE'S THE CODE Public Sub ProcessRequest(ByVal context As System.Web.HttpContext) Implements System.Web.IHttpHandler.ProcessRequest ''# the page contenttype is plain text' HttpContext.Current.Response.ContentType = "text/pla...

How to make linq master detail query for 0..n relationship?

Given a classic DB structure of Orders has zero or more OrderLines and OrderLine has exactly one Product, how do I write a linq query to express this? The output would be OrderNumber - OrderLine - Product Name Order-1 null null // (this order has no lines) Order-2 1 Red widget I tried this query but is no...

Using Count with Take with LINQ

Is there a way to get the whole count when using the Take operator? ...

Entity framework 4.0 compiled query with Where() clause issue

Hello, I encountered with some strange behavior of System.Data.Objects.CompiledQuery.Compile function - here is my code for compile simple query: private static readonly Func<DataContext, long, Product> productQuery = CompiledQuery.Compile((DataContext ctx, long id) => ctx.Entities.OfType<Data.Product>().Where(p => p.Id ...

Using LINQ to isolate a particular obect from a list of objects

Hello All, I am trying my hand at making an invaders clone. there are 30 aliens arranged in a 5x 6 matrix on screen. I need to give the bottom most alien the ability to fire a shot. I am using LINQ to group the aliens into 5 groups based on Location.X and then sort the groups descending.I then need to choose one of the groups ( that ...

Manipulating existing XDocument (fails)

Hi there, I got the following Code snippet from my Silverlight Application: var messages = from message in XcurrentMsg.Descendants("message") where DateTime.Parse(message.Attribute("timestamp").Value).CompareTo(DateTime.Parse(MessageCache.Last_Cached())) > 0 select new ...