linq

Using Linq to filter a ComboBox.DataSource ?

Hi board, in another topic, I've stumbled over this very elegant solution by Darin Dimitrov to filter the DataSource of one ComboBox with the selection of another ComboBox: how to filter combobox in combobox using c# combo2.DataSource = ((IEnumerable<string>)c.DataSource) .Where(x => x == (string)combo1.SelectedValue); I would like t...

Array.BinarySearch where a certain condition is met

I have an array of a certain type. Now I want to find an entry where a certain condition is met. What is the preferred way to do this with the restriction that I don't want to create a temporary object to find, but instead I only want to give a search condition. MyClass[] myArray; // fill and sort array.. MyClass item = Array.BinaryS...

Linq-to-XML query to select specific sub-element based on additional criteria

My current LINQ query and example XML are below. What I'd like to do is select the primary email address from the email-addresses element into the User.Email property. The type element under the email-address element is set to primary when this is true. There may be more than one element under the email-addresses but only one will be...

asp.net update LINQ dbml files

Is there a quick and easy way to update my LINQ dbml files? Right now, if I update a Stored Procedure, I need to open the dbml designer file, delete the old SP, save, drag and drop the new SP, and save again. Dont' get me wrong, this isn't "hard"... just with all the fancy new technology out there, it would be nice to be able to just ri...

How to update Child grid in asp.net using LINQ

Hi I have an asp.net page where i am using LINQdatasource to bind grid. Now whenever, if some one changes something in grid I want to update a history table. which is also shown as child grid for each row Let say I have a grid with two column Name and Age. it also has a child row with column field and datetime. so when ever if some on...

LINQ Query Problem

I want to use this in my application but I'm getting an error for GetByLatest().Cast<IRss>(); I am getting an error to this line GetByLatest(),please tell how shall I implement this one Please suggest a solution IList<IRss> news = new Trytable().GetByLatest().Cast<IRss>(); return new RssResult(news, "William Duffy - Glasgow Based AS...

GetByLatest in LINQ ?

hello all, Please provide me a solution for GetByLatest it is giving me an error How to use this "GetByLatest" IList<IRss> news = new Trytable().GetByLatest().Cast<IRss>().ToList(); i used this way in the controller,still it is giving an error for getbylatest in the feed method public static IEnumerable GetByLatest(this IEnumerable...

Implementation Of Inbound rss Feed in Mvc

Hello All, Please can I get the sample code of Implementation Of Inbound Rss In Mvc. Please help me its very urgent. Thanks Ritz ...

Running an existing LINQ query against a dynamic object (DataTable like)

Hello, I am working on a generic OData provider to go against a custom data provider that we have here. Thsi is fully dynamic in that I query the data provider for the table it knows. I have a basic storage structure in place so far based on the OData sample code. My problem is: OData supports queries and expects me to hand in an IQuer...

linq null refactoring code

i have code public List<Files> List(int? menuId) { if (menuId == null) { return _dataContext.Files.ToList(); } else { return _dataContext.Files.Where(f => f.Menu.MenuId == menuId).ToList(); } } is it possible to make it only one line like return _dataContext.Files.Where(f => f.Menu.MenuId == men...

problem with a join

I have this code: int se = (int) settings.GruppoSegreteria; var acc = db.USR_Accounts.Where( p => p.ID_Gruppo == se); var segreterie = from s in db.USR_Utenti join h in acc on s.ID equals h.USR_UtentiReference select s; And this error: The type of one of the expressions in the join c...

LINQ grouping by and creating a formula based on the returned results

I need some help adding conditions to a linq query. Take this small example static void Main(string[] args) { List<ItemEntry> items = new List<ItemEntry>(); items.Add(new ItemEntry(1,1,5,1)); items.Add(new ItemEntry(2, 1, 5, 1)); items.Add(new ItemEntry(3, 1, 5, 1)); items.Add(new ItemEntr...

problem writing xml to file with .net mvc - timeout?

Hey, so having an issue with writing out to an xml file. Works fine for single requests via the browser, but when I use something like Charles to perform 5-10 repeated requests concurrently several of them will fail. The trace simply shows a 500 error with no content inside, basically I think they start timing out waiting for write acces...

Build dynamic LINQ?

I'm using LINQ to query data. Consider a case where the user only wants to report on say 1 of the 3 fields? (see below) Can anyone tell me how to build the query dynamically? Thanks DD var query = from cl in db.tblClaims join cs in db.tblCases on cl.ref_no equals cs.ref_no where cl.claim_status == "Appeal" ...

Fast serarch of 2 dimensional array

I need a method of quickly searching a large 2 dimensional array. I extract the array from Excel, so 1 dimension represents the rows and the second the columns. I wish to obtain a list of the rows where the columns match certain criteria. I need to know the row number (or index of the array). For example, if I extract a range from excel...

Advanced Linq query using into

I have this query that someone else wrote, it's over my head so I'm looking for some direction. What is happening currently is that it's taking numbers where there is a goal and no history entered, or history and no goal, this screws up the calculations as both goal and history for the same item are required on each. The three tables ...

Public property List needs to Concat 2 types with inheritance

I have 2 lists: one of type A and one of type Aa. type Aa is inherited from type A. So: List<A> listA = new List<A>(); List<Aa> listAa = new List<Aa>(); with class Aa : A I have: public property Lists<A> { get { List<A> newList = new List<A>(); //return concat of both lists foreach(List l in listA) { ne...

Can we control LINQ expression order with Skip(), Take() and OrderBy()

I'm using LINQ to Entities to display paged results. But I'm having issues with the combination of Skip(), Take() and OrderBy() calls. Everything works fine, except that OrderBy() is assigned too late. It's executed after result set has been cut down by Skip() and Take(). So each page of results has items in order. But ordering is done...

linq to xml. read. and assign to ViewData..noob

I have some xml similar to this: <?xml version="1.0" encoding="utf-8" ?> <data> <resources> <resource key="Title">Alpha</resource> <resource key="ImageName">Small.png</resource> <resource key="Desc">blah</resource> </resources> </data> using linq-xml how can i assign each resource here as a key value pair w...

Property in class is IEnumerable<TDto> get TDto.A == a

So I have a class is something like this public class Order { //some other stuff ... //setting the internal _orderItems collection ... IEnumerable<OrderItems> OrderItems { get { return _orderItems; } } public class OrderItem { //other stuff public string ProductName {get; set;} } If I have a collection of orders...