Tag linq

[Solved] Print non repeating combinations [closed]

Interesting task. Try following code: List<string> list = Enumerable.Range(1, 6).Select(e => ((char)(‘A’ + e – 1)).ToString()).ToList(); List<string> temp = new List<string>(); int count = list.Count; int total = 1 << list.Count; for (int i = 0; i < total; i++)…

[Solved] Convert SQL into LINQ and Lambda

Maybe something like this: var result= ( from s in db.Stands join cp in db.ContractProducts on s.Id equals cp.StandId join p in db.Products on cp.ProductId equals p.Id where s.EventId == 1 group p by p.Description into g select new {…

[Solved] Whats is Linq equivalent for SQL query with OR-joins? [duplicate]

You could also do a cross join with a where condition similar to your inner join condition var q1 = from billMap in tblOfferingBillingBehaviorMapping from lkpBill in tblLookUpBillingBehavior where billMap.LkpBillingBehaviorId == lkpBill.LkpBillingBehaviorId || billMap.LkpBillingBehaviorId =lkpBill.ParentRootId select new { billMap, lkpBill…

[Solved] How to sort matrix column values then rows?

You will need a row comparer. We’ll keep in mind that all rows have same length: public class RowComparer : IComparer<IEnumerable<int>> { public int Compare(IEnumerable<int> x, IEnumerable<int> y) { // TODO: throw ArgumentNullException return x.Zip(y, (xItem, yItem) => xItem.CompareTo(yItem)) .Where(c…

[Solved] Sort a String Array containing Numbers in linq

That happens because you do a string comparison – you should change that to a int comparison string[] arr = { “3”, “1”, “6”, “10”, “5”, “13” }; var result = arr.OrderBy(int.Parse).ToArray(); 1 solved Sort a String Array containing Numbers…

[Solved] Checking For null in Lambda Expression

Based on “I am trying to get the null, empty string, and source components out of a List” I assume you mean you want a list with these 3 specific values. var allItems = itemsList .Where(s => string.IsNullOrEmpty(s[Constants.ProductSource]) || s[Constants.ProductSource]…

[Solved] c# linq to xml subnodes query [closed]

Do you mean something like this: var song = “foo2.mp3”; var number = 2; var query = from x in xd.Root.Elements(“file”) where x.Element(“song”).Value == song from y in x.Elements(“listen”) where (int)y.Element(“number”) == number select y.Element(“data”); Which would give you: solved…