linq

ISNULL() in LINQ to XML

Dear All, SELECT * FROM CUSTOMERS WHERE RTRIM(ISNULL([SHORTNAME],'')) LIKE '%john%' I want to write this using Linq, var persons = from person in xmlDoc.Descendants("Table") where person.Element("SHORTNAME").Value.Contains("123") select new { shortName = person.Element("SHORTNAME").Value, longName = person.Element("LONGNAME").Va...

Help needed to create LINQ Summary Line

Hi all I have got the following LINQ query, apologies for the poor variable naming. Dim bla3 = From c In crdc.SRAs _ Where c.acad_period = ReviewCredential.AcadPeriod _ And c.periodID = ReviewCredential.PeriodID _ And c.aos_code = ReviewCredential.AoSCode _ And c.aos_period = ReviewCredential...

Preserve input with LINQ expression using Except instead of Where

Given this LINQ expression: items.Select( i => i.ToLowerInvariant() ).Except( keywords ) Is there a way to express that where you preserve the casing of the input, without using a Where()? The Where approach: items.Where( i => !keywords.Contains( i.ToLowerInvariant() ) ) I like the way the Except approach reads, but I don't want t...

Sorting a Dictionary<string,Dictionary<string,string>> by the value of the inner Dictionary value using LINQ?

I can't seem to wrap my head around this one. I need to sort a Dictionary by the value of an inner Dictionary using LINQ. Any thoughts? ...

LINQ VB how to select records with the max date (highest date)

I know how to do this in C#, but my dev team doesn't use C#... here is the answer in C#: http://stackoverflow.com/questions/470440/linq-how-to-select-only-the-records-with-the-highest-date How do I do this in VB? Essentially, if I knew how to write lambda expressions in VB, I would be set, but the materials I have found are not helpfu...

Is it always possible to do something in SQL if you could do it in Linq?

I'm trying to write a SQL Statement that should function like the below Linq query. Mainly, I want to sum two columns (Cash and Check) out of one column (Value * Quantity) based on a certain condition (Type == "Check"). So, if the Type is "Check", then put the value in the Check column, otherwise put it in the Cash column. Linq: from a...

Using LINQ's Except<> method with an object from an external API

Hi, I have a List<> of HTMLAnchor objects (HTMLAnchor is an object from an external API). I want to exclude clicking on some of the links as they are for logging out, etc. Using LINQ, I can use the Except operator. However, on here (http://msdn.microsoft.com/en-us/vcsharp/aa336761.aspx#except1), the example using the custom type (Prod...

Why doesn't this LINQ Query Work?

I was attempting to help someone else out and wrote this query: var foundTab = (from tab in tabControl1.TabPages where tab.Name == "tabName" select tab).First(); And they reported that they received this error: Could not find an implementation of the query pattern for source type System.Windows....

LINQ Is it possible to get a method name without a return type via LINQ expression trees?

Hi! I know it is possible to retrieve a property name or a method with a return type. But is it also possible to get a method name without a return type via LINQ expression trees? Example: string methodname = GetMethodname(x=>x.GetUser()); ---> results: "GetUser" ...

Linq objects through webservice to other projects?

Hi Chaps, I created a new solution with 3 projects: My "Client" is a ASP.Net Web Application. This should display the information. My Businesslayer should have all logic in it, it's designed as a normal class libery. My "Server" is a WebService. This connect via Linq to the database and get the Information. Now only my Server knows Lin...

convert this LINQ expression into Lambda..

Hi Guys, I have a hard time converting this below linq expression(left join implementation) to lambda expression (for learning). var result = from g in grocery join f in fruit on g.fruitId equals f.fruitId into tempFruit join v in veggie on g.vegid equals v.vegid into tempVegg from joinedFruit in tempFruit.Defa...

Linq to sql convert IQueryable to Dataset

What is the easiest way to convert an IQueryable object to a dataset? ...

how to make c# method more functional using C# and Linq

private void DoSomeWork() { ManualResetEvent[] waitEvents = new ManualResetEvent[rowCount]; int i = 0; foreach (DataRow row in StoredProcedureParameters.Tables[0].Rows) { waitEvents[i] = new ManualResetEvent(false); var workerClass = new WorkerClass(); var collection = new Dictionary<string, obj...

Nested Linq to created multiple class objects

Hello, I am looking to create a dynamic XML navigation menu, which is made of MenuItem's and SubMenuItem's (both classes). I want to parse the following XML and use LINQ to parse it and retrieve the data. Here is a sample XML: <?xml version="1.0" encoding="utf-8" ?> <MenuItems> <Item Id="1" Url="Default.aspx" LinkText="Home" Descr...

C# write to Excel using Linq

Hi, I'm writing an app where i need to retrieve some rows from a DB and dump them into an excel spreadsheet. I'm using Linq to retrieve these rows. is it possible to dump these rows directly into their couterparts in the excel sheet... (where one cell of excel corresponds to one cell of the DB) Thanks, RP ...

Core Data and MySQL

How would I create a core-data application that syncs with a MySQL database? Should I implement a SQL-Lite layer and try to sync with MySQL that way? Or would running web services be better? I want to take advantage of Core Data modeling though. Is there any way to use Linq? I love linq. ...

Linq with MySql

Is there a free solution for using Linq and MySQL? Can one use Visual Studio Express, Linq, and MySQL together? ...

LINQ sorting special characters first?

It looks like special characters are not being regarded when sorting with LINQ and I didn't expect it to. Anyway, I need to sort special characters so they appear first in a list. Any ideas? I know I can do something like: http://stackoverflow.com/questions/921107/use-linq-for-arbitrary-sorting, but how do I allow the sort to extend pass...

ASP.NET GridView with LinqDataSource: Remeber Sorting, Paging and WhereParameters state

I'm using a standard GridView with a LinqDataSource. The user can sort and page through the grid using the stock standard stuff. Searching criteria (WhereParameters) can also be used to filter the results. This works great, but the state is obviously lost whenever navigating away from the page. So a generic mechanism of capturing the So...

searching a List<>

I have a List<Order> public int OrderID { get; set; } public string CustID { get; set; } public string Details { get; set; } I want to write a method that accepts a ID, then searches this List for matching records that have same CustID and returns ORderID and Details in a List<> ...