linq

How to 'select new' inside Linq lamda expression?

How do i do this in one statement vs breaking up in two? var newpeople= _rep.GetPeople().Where(p=>p.personID).Select(new KindoFPerson...id=p.id etc) ...

How do I delete records from a child collection in LINQ to SQL?

I have two tables in my database connected by foreign keys: Page (PageId, other data) and PageTag (PageId, Tag). I've used LINQ to generate classes for these tables, with the page as the parent and the Tag as the child collection (one to many relationship). Is there any way to mark PageTag records for deletion from the database from wi...

How do I Filter LINQ query by date?

query = query.Where(q => q.Date.ToString().Contains(strDate)); Above statement is not correct. If I use "==" Then it will match exact date. That is O.K. but can I filter, Like we filter strings ?? ...

how group by in Linq with 2 Field ?

how group by in Linq with 2 Field ? (from i in info group i by i.OrderId into g select new { orderId = g.Key, infos = g }); not only order by with order Id but with two field like ... group by i.orderId And i.City how this will do? ...

LINQ to SQL updates

Does any one have some idea on how to run the following statement with LINQ? UPDATE FileEntity SET DateDeleted = GETDATE() WHERE ID IN (1,2,3) I've come to both love and hate LINQ, but so far there's been little that hasn't worked out well. The obvious solution which I want to avoid is to enumerate all file entities and set them manua...

LINQ: How to declare IEnumerable[AnonymousType] ?

Hello, This is my function: private IEnumerable<string> SeachItem(int[] ItemIds) { using (var reader = File.OpenText(Application.StartupPath + @"\temp\A_A.tmp")) { var myLine = from line in ReadLines(reader) where line.Length > 1 let id = int.Parse(li...

Can't bind a GridView to a LINQ to SQL Result

OK, I am amittedly new to LINQ and have spent the last week reading everything I could on it. I am just playing around, trying to follow some examples I have found (a PDF from Scott Gu on the topic, in fact) and I am at a complete loss. Can someone please tell me why, when I bind a GridView to the query below, using the code below, I g...

JOIN with LinqtoSql, only select TOP(x) on joined table?

I've had a look around on StackOverlow but haven't been able to find a definitive answer on this. Below I have a code snippet of what I currently have, and I will explain what I am trying to achieve. Table<Gallery> galleries = pdc.GetTable<Gallery>(); Table<GalleryImage> images = pdc.GetTable<GalleryImage>(); Table<Comment> comments = ...

Retrieving object and child collection in NHibernate using Linq

Hi, I have a problem using Linq to NHibernate to load an object and eagerly load a child collection. The objects look like this: public class Order { public Guid Id {get; set; } public IList<OrderLine> OrderLines {get;set;} } public class OrderLine { public Guid Id {get;set;} public string Item {get;set;} } I am tryi...

Export DBML to SQL script

Due to a harddrive crash, I lost my SQL server database files for a project I was creating. I still have my DBML files I used in my .NET project, so I still have the database structure in a file. Is it possible to export my DBML somehow to a SQL server script, to recreate my databases in SQL server. ...

Return Enumerable value from Class in linq?

i need Enumarable value from below class but give error public static Enumerable LoadDataByName(string name) { List<StuffDepartman> Stuff = (List<StuffDepartman>)HttpContext.Current.Session["Stuffs"]; var stuffs = from s in Stuff select s; stuffs = from s in Stuff where s.Name = name s...

How to handle Null in LINQ Subquery?

I've got a subquery that returns the most recent value from a child table. In some cases the subquery returns nothing. The query below fails at runtime because the inferred type of MemberPrice is decimal and is not nullable. Simplified query: Dim q = From s In dc.STOCKs _ Select s.ID, MemberPrice = _ (From mp In dc...

sorting variable multidimensional arrays

I have the array of integers: d[]. for example(7 columns and some rows): 4 1 8 0 3 2 6 7 0 4 9 1 1 5 0 6 1 3 5 2 0 and so on. At compile time I do not know how many columns has array d. And I do not know at compile time which columns to use to orderby. For example need to sort by: d[5], d[2], d[0], d[3]. But at run time I know or...

Parsing HTML document: Regular expression or LINQ?

Trying to parse an HTML document and extract some elements (any links to text files). The current strategy is to load an HTML document into a string. Then find all instances of links to text files. It could be any file type, but for this question, it's a text file. The end goal is to have an IEnumerable list of string objects. That par...

Writing an anonymous method for a method in IEnumerable

I have the following code (calling a method returning IEnumerable): FibonacciWithLinq.Skip(delegate() { return 5; } ); The parameter for skip takes an int (number of items to skip). I could have a seperate function which would determine this number (it may be dependent on som...

select rows that do not have any foreign keys linked

i have 2 tables Group and People People has GroupId that is linked to Group.GroupId (primary key) how can I select groups that don't have any people? in t-sql and in linq thank you ...

The state of LINQ to NHibernate ActiveRecord

Hi, Does anyone know if the LINQ to NHibernate ActiveRecord is ready for production? I'm about to start a project that has some tight modelling deadlines. ActiveRecord looks like a winner as opposed to my previous experiences with LINQ to SQL. LINQ to SQLs db first is nice, but somewhat cumbersome after a while. What makes LINQ to SQL ...

Update using linq

how can i update a record against specific id in (Linq to sql) ...

Linq update record

how update a record on specific id in linq + asp.net c# ...

How to get elements from collection A that not in collection B? i.e. A-B

Possible Duplicate: Disjoint Union in LINQ DUPE: http://stackoverflow.com/questions/801757/disjoint-union-in-linq I know this is a simple collection operation,My code is: var gone = from a in A where B.Contains(a) == false select a; but it not work. ...