Can you use LINQ types and extension methods in IronPython?

IronPython 2.7 finally bridges this gap with the clr.ImportExtensions method which adds the extension methods from a namespace to the target types e.g. >& ‘C:\Program Files\IronPython 2.7\ipy.exe’ IronPython 2.7 (2.7.0.40) on .NET 4.0.30319.225 Type “help”, “copyright”, “credits” or “license” for more information. >>> import clr >>> clr.AddReference(“System.Core”) >>> from System.Collections.Generic import List >>> dir (List) … Read more

How to order child collections of entities in EF [duplicate]

You could load the data and sort in memory after loading it. IEnumerable<Team> teams = _ctx.Teams .Include(x => x.TeamMembers) .Include(x => x.TeamMembers.Select(u => u.User)) .Where(x => x.UserId == ownerUserId) .OrderBy(x => x.Name).ToList(); foreach (var team in teams) { team.TeamMembers = team.TeamMembers.OrderBy(m => m.Name); foreach (var teamMember in team.TeamMembers) { teamMember.Users = teamMember.Users.OrderBy(u => u.Name); } … Read more

LINQ across multiple databases

You can do this, even across servers, as long as you can access one database from the other. That is, if it’s possible to write a SQL statement against ServerA.DatabaseA that accesses ServerB.DatabaseB.schema.TableWhatever, then you can do the same thing in LINQ. To do it, you’ll need to edit the .dbml file by hand. You … Read more

How to dynamically add OR operator to WHERE clause in LINQ

You can use the PredicateBuilder class: var searchPredicate = PredicateBuilder.False<Songs>(); foreach(string str in strArray) { var closureVariable = str; // See the link below for the reason searchPredicate = searchPredicate.Or(SongsVar => SongsVar.Tags.Contains(closureVariable)); } var allSongMatches = db.Songs.Where(searchPredicate); LinqToSql strange behaviour

Why is the LINQ “apply-to-all” method named Select?

It’s really identical to map from functional languages. The reason it’s named Select is that it’s designed to be used as a part of LINQ which uses SQL-like keywords. from item in collection where item.Value == someValue select item.Name is translated to: collection.Where(item => item.Value == someValue) .Select(item => item.Name) it would be a little … Read more

How does LINQ Except work? [duplicate]

Taken from 101 LINQ Samples: int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 }; int[] numbersB = { 1, 3, 5, 7, 8 }; IEnumerable<int> aOnlyNumbers = numbersA.Except(numbersB); Console.WriteLine(“Numbers in first array but not second array:”); foreach (var n in aOnlyNumbers) { Console.WriteLine(n); } Result Numbers in first array but not second … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)