Click here to Skip to main content
15,885,141 members
Everything / Lambda

Lambda

lambda

Great Reads

by Ivan Perevernykhata
How to start/stop RDS instances on schedule with aws-sdk, nodeJs Lambda function and CloudWatch
by JIANGWilliam
This is the first of three episodes to introduce considerations and techniques used for the throwable functional interfaces defined in my open-sourced library functionExtensions.
by Randy Kroeger
Created a POC that dynamically builds a predicate using Expression and Reflection.
by Pradip Koli
Using NoSQL DBreeze database with ASP.NET on SQL Northwind Database.

Latest Articles

by P. Erward
How to put the AWS Lambda C++ Runtime into a Lambda layer and how to use it
by egoebelbecker
Create an AWS Lambda in five minutes
by Necmettin Demir
To provide a URL link to access objects in private S3 bucket through AWS Cognito User Pool (using hosted UI), Authorized API Gateway and Lambda in a Secure Way.
by PaulKukiel
Build a Custom PHP MVC in 30 mins and deploy to AWS lambda

All Articles

Sort by Score

Lambda 

5 Jun 2017 by Ivan Perevernykhata
How to start/stop RDS instances on schedule with aws-sdk, nodeJs Lambda function and CloudWatch
8 May 2018 by JIANGWilliam
This is the first of three episodes to introduce considerations and techniques used for the throwable functional interfaces defined in my open-sourced library functionExtensions.
29 May 2014 by Randy Kroeger
Created a POC that dynamically builds a predicate using Expression and Reflection.
16 May 2018 by Clifford Nelson
var results = owners.Where(b => b.Cars != null) .GroupBy(o => o.Gender, o => o.Cars, (key, g) => new Result { Gender = key, Name = g.SelectMany(cars => cars) .Select(car => car.Name).Distinct().OrderBy(k => k).ToList() }); I forgot the...
22 Jul 2014 by Pradip Koli
Using NoSQL DBreeze database with ASP.NET on SQL Northwind Database.
29 Dec 2015 by Peter Carrasco
This article describes a pub-sub model using AWS Lamdba along with SNS to keep your AWS-hosted RDMB system of record and cache in sync.
11 Dec 2016 by Jon McKee
var query = from row in table where row.IdUnit == 10 && row.IdSection == 5 group row by row.IdSystem into rowGroup let count = rowGroup.Count() orderby count descending select new { IdSystem = rowGroup.Key, Count = count...
23 May 2021 by Uladzislau Baryshchyk
A walkthrough and source code for creating telegram bot using C# and deploying it on AWS
23 Dec 2012 by Mehdi Gholam
Posted from the comment:Check if the "optimize code" is set in your project.
14 Aug 2014 by TheCannyCoder
Reductions and Short-Circuiting Operations
6 Dec 2014 by Joezer BH
You may use Linq2Sql's DataContext.GetCommandDbCommand dc = db.GetCommand(TheQeury);Check out the msdn article on the method[^][added]ORSee linqpad[^] (as suggested by Eliyahu in the thread above, I am not sure what the "lightweight" free version includes...
4 Jul 2015 by FranzBe
void Main(){ List objItems = getSampleData(); // for linqpad objItems.Dump(); var result = objItems.GroupBy(x => new { x.Project, x.State }) .Select(g => { var a = g.ToList(); return ...
18 Jan 2016 by Sascha Lefèvre
I don't know if it can be done with AutoMapper. But this is how you could do it yourself, not including the Repository-call. There's a generic and non-generic version of the mapping-method; I think you should be able to use the generic one.using System;using...
27 Nov 2016 by Wendelius
First of all, this is a very well formulated question with example data, nicely done!One quite simple way could be to use two separate queries, one for fetching top salaries and the second one for employees, for examplevar topSal = from x in Employees group x by x.Salary into...
1 Sep 2017 by Graeme_Grant
Something like... var resultantList = sigList .Where(x => !string.IsNullOrEmpty(x.SignalGroup)) .GroupBy(s => s.SignalGroup) .Select(grp => grp.ToList());
12 Jul 2019 by Richard Deeming
As discussed in the comments, the code you've shown is correct, and the bug has now disappeared. Demo: Optional Xml | C# Online Compiler | .NET Fiddle[^]
7 Oct 2019 by Maciej Los
Sorry, your question is unclear and/or your database is wrongly designed, because schoold.id and class.id can NOT be equal! A database model should looks like: 1 School => ∞ YearBooks 1 YearBook => ∞ Classes 1 Class => ∞ Students So, you need at least 4 objects (tables): 1. Yearbooks table - ...
11 Jan 2020 by Maciej Los
This should've done the trick: var result = table2.Where(second=>second.columnf == 0 && table1.Any(first=>first.columnb == 4 && first.columna == second.columna)) .ToList();
28 May 2020 by Maciej Los
Try: var result = Myentity.Person .Where(x=>x.per==123) .GroupBy(x=>new {x.a, x.b}) .Select(grp=> grp.OrderByDescending(x=> x.d).First()) .ToList();
2 Jun 2020 by Maciej Los
Start here: Perform inner joins (LINQ in C#) | Microsoft Docs[^] Perform left outer joins (LINQ in C#) | Microsoft Docs[^] When you get stuck, come back here, provide your code, describe your issue and wait for response.
8 Aug 2020 by Vlad Neculai Vizitiu
Mocking/stubbing lambda expressions to have a bit more control over our unit tests
31 Dec 2012 by John Bandela
This post discusses another alternative to lambda move capture.
1 May 2013 by jsolutions_uk
I'm not sure it is possible with lambdas, it's looking rather like a polymorphic lambda. check here[^]. I just don't think lambdas were intended to be used in the context of template based generic programming.The closest I have managed to get to implementing what you have above is...
14 Jan 2018 by maheshbisht
I have a list of class public class PrintUTAccural { public string PropertyName { get; set; } public string VendorName { get; set; } public string VendorNumber { get; set; } public string InvoiceNumber { get; set; } public...
16 Jul 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Here x * y indicates that the elements will be aggregated by multiplication.Refer - C# Aggregate[^].See the examples and their outputs. You will be clear.Quote: int[] array = { 1, 2, 3, 4, 5 }; int result = array.Aggregate((a, b) => b + a); // 1 + 2 = 3 // 3 + 3 = 6 // 6...
16 Jul 2013 by OriginalGriff
A lambda is pretty much just a method without a name. The (x,y) part before the => specifies the parameters and the x * y part after it is the body of the function.In this case, what you are doing is the equivalent of: List lst = new List { 1, 2, 3, 4 }; int...
30 Nov 2013 by Karthik_Mahalingam
Try these linkmight be useful for you.C# Delegates, Anonymous Methods, and Lambda Expressions – O My![^]this link contians basics of lambda very informative...
2 Jul 2014 by TheCannyCoder
Ranges and looping with IntStream
3 Nov 2014 by Jeroen E
I figured it out after I came across this link http://stackoverflow.com/questions/2247051/how-to-use-selectmany-with-dataservicequery[^]I turned the query around by first querying and filtering the recruiters and then the addresses.The query ended up like this:var addressesQuerry =...
11 Dec 2014 by mukesh mourya
var result = dm.Challan_Totals .Join(dm.Challans, ct => ct.Challan_No, c => c.Challan_No, (ct, c) => new {...
21 Mar 2016 by v7777
Select() method works as projection. So it always will return class with properties.so your lambda expression should look like by that wayif (!string.IsNullOrWhiteSpace(utility)){ submissions = submissions .Where(s => s.SummaryBillMaster.BillingGroupFacilityCollection...
19 Apr 2016 by Richard Hyatt
Part 2 of our series on simplifying and securing AWS Lambda code using Node.js
8 Aug 2016 by Karthik_Mahalingam
try thisDataTable DT = new DataTable();DT.Clear();DT.Columns.Add("نام");DT.Columns.Add("نام خانوادگی");DataTable dtNew = db.TblUsers.Where(x => x.Id != 0).Select(k => { var row = DT.NewRow(); row.ItemArray = new object[] { k.Name, k.Family }; return row; }).CopyToDataTable();
12 Aug 2016 by Karthik_Mahalingam
try thisvar result = YourList.GroupBy(k => k.Section).Select(grp => new { Section = grp.Key, Count = grp.Count() }).ToList();
11 Oct 2016 by Ali_100
I am in trouble, tried many times but could succeed , foreach (var tempitem in mbsRateTempList) { foreach (var Saveditem in mbsSavedRecordList) { if (tempitem.MbsSecurityId == Saveditem.MbsSecurityId && tempitem.CouponRate ==...
27 Nov 2016 by sunil kumar meena
I was trying simple thing, form a collection of employees I want to fetch top two maximum employees list. But remember there can be multiple employee with the same salary so I want all of them if they fall in max two salary range. below is my collection that I am using:List Employees...
5 Dec 2016 by Ehsan Sajjad
In dynamic linq, the string parameter passed in is just normal sql, not any lambda expressions, so your condition should be like: case "0": query += "OperatorLineId = OperatorLineId "; break;default: query += string.Format("OperatorLineId =...
13 Dec 2016 by Andy Lanng
I should make you aware of apps like Linqer | SQL to LINQ converter[^] before I continue. These types of app translate sql to linq syntax.Here's what I got for lamda:var results = db.CMMS .Where(c=>c.Unit == prop1 && c.Section == prop2) .GroupBy(c=>c.Component) ...
13 Dec 2016 by Richard MacCutchan
See LINQ: .NET Language Integrated Query[^] and Lambda Expressions (C# Programming Guide)[^].
21 Dec 2016 by Suvendu Shekhar Giri
Try-"01:33:56:00" instead of "001:33:56:00"That extra 0 can cause the problem.Hope, it helps :)
21 Dec 2016 by Peter Leow
Where and how are these "01:33:56:00","00:23:34:00" stored?Check this out TimeSpan.Parse Method (String) (System)[^], pay particular attention to the parameter format under Remarks[ws][-]{ d | [d.]hh:mm[:ss[.ff]] }[ws]
1 Sep 2017 by Andy Lanng
More like: var resultantList = sigList .Select((x,i) => new {Item=x,Index=i}) .GroupBy(a => string.IsNullOrEmpty(a.Item.SignalGroup)?a.Index.ToString():a.Item.SignalGroup) .Select(grp => grp.Select(a=>a.Item).ToList()); Let me break it down: You want to have each empty string in...
20 Oct 2018 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it contains null - which...
4 Mar 2019 by #realJSOP
I would do it this way: CurrentFinancialMovementData movementData = null; { CurrentFinancialMovementData movement1 = keys.OrderByDescending(s => s.LatestReserveDate) .ThenByDescending(x => x.ReserveDaySequence) ...
7 May 2019 by BillWoodruff
To me this kind of code ... that will obviously not compile ... indicates you have not really studied the basics of using the powerful tools that Linq provides. Don't worry, though: everyone I know has gone through a learning curve to get somewhat fluent in using Linq :) Well, okay, imho,...
3 Sep 2019 by OriginalGriff
Try: var selected = studentsCollection.Where(s => s.ID == 3); or Student justTheOne = studentsCollection.Where(s => s.ID == 3).FirstOrDefault();
17 Dec 2019 by Richard Deeming
The Where condition can only use properties from the projection it operates on. Move the Where before the Select (and fix the other syntax errors) and it will work. var tableA = MyStudentEntities.Where(x => x.ColumnD == 1).Select(x => new { x.ColumnA, x.ColumnB, x.ColumnC });
8 Jan 2020 by Maciej Los
Seems you want to create a where statement dynamically. So, please read this: How to use expression trees to build dynamic queries (C#) | Microsoft Docs[^] Here[^], you you'll find quite simple example.
7 Mar 2020 by James A. Brannan
In this tutorial, you create a simple Python client that sends records to an AWS Kinesis Firehose stream.
29 Mar 2020 by Maciej Los
Seems, you don't understand what OriginalGriff has already told you... So, i'll try to show you an example. Imagine, you have a Person class: public class Person { private string personname = string.Empty; private DateTime dob = new...
27 May 2020 by Richard MacCutchan
Lambda expressions - C# Programming Guide | Microsoft Docs[^]
14 Jun 2021 by PaulKukiel
Build a Custom PHP MVC in 30 mins and deploy to AWS lambda
24 Jun 2021 by Richard Deeming
Trying to push the condition to the database query will result in poor performance. Instead, only add the condition if it is required: var deleteItems = _EFContext.DbTable.Where(so => so.Identifier == ProviderIdentifier); if...
24 Nov 2020 by PaulKukiel
How to build and deploy a Typescript lambda function with AWS CDK and Deno layer
4 Dec 2012 by sadomovalex
Shows how using reverse engineering feature developers may add new conditions into string CAML queries using lambda expressions.
23 Dec 2012 by Sander Rossel
So I'm having a very weird problem... I'm working on a project which does some Reflection stuff. One of the things it does is read the name of methods. I've got code that, in essence, looks like the following.Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As...
6 Jan 2013 by dartfrog
Hi all, currently i'm facing the problem with nested linq.here is my tables and now i am developing MVC4 Razor web application.student student_id,studentname,descriptionbook book_id,student_id,bookname,checkitoutbooker bookerid,book_id,bookername,bookerdescriptioni create...
6 Jan 2013 by Christian Graus
You need to do a three way join, you can't put LINQ code inside the new block, that needs to just be a constructor for your object.
9 Jan 2013 by Jochen Arndt
When using similar names in different scopes, at least one must be prefixed. Because you are implementing code inside class declarations, you must use this here. Imagine that the code is inline and the code block is copied as-is to the location where the function is called before compilation...
10 Jan 2013 by H.Brydon
You might be running into problems with access. The first line of your class isclass CMyWnd : CDialog {and it should probably beclass CMyWnd : public CDialog {
30 Apr 2013 by User 583852
I want to do something like thistemplate T& {val++; return val;} >class RangeAllocator...where IncrementorT is a user replaceable functor that RangeAllocator will use to increment values. I know I can do it using a struct but I'm...
1 May 2013 by Stefan_Lang
I know you can use functions as template parameters[^]. I suppose it could work with lambdas, but I have not tried myself.
13 May 2013 by Mohammed Hameed
Ideally, how many lines of code (max) should be written in a Linq/Lambda expression?Thanks!
22 May 2013 by vibhu12345
string VenderNumber = UtAccuralLstForComp.Where(x => x.VendorName == Name).SingleOrDefault().VendorName
16 Jul 2013 by Chaitanya Pai
Please consider this example, List lst = new List { 1, 2, 3, 4 }; int result = lst.Aggregate((x, y) => x * y);As per the articles (x,y) specifies input parameters and x*y as implementation, my doubt is, aggregate() is the method of list, then it has to have inner...
27 Nov 2013 by Trapper-Hell
Dear all,I am using lambda expressions in C# in order to filter within a database entity. The table I am accessing is using a hierarchical tree structure and a particular entity can have infinite levels of children, which can be accessed by .Children, for example:string name =...
28 Nov 2013 by Trapper-Hell
I have finally solved by starting from the leaf and work myself up to the parents in order using query joins, such as:query = query.Join(subquery, c => c.ParentId, p => p.Id, (c, p) => p);Thank you anyway.
19 Dec 2013 by Prutal
iam using entity framwork i need to get a user friends the diagram are in the picturethis is the diagram of the tablesInt64 userID =1;ctx.Users.Where(x => x.FriendShips.All(y => y.Accepted == true && y.CreatorID == userID)).ToList();
19 Dec 2013 by bowlturner
Well it might help to know what results you are expecting and what you are actually getting.currently what you have herey => y.Accepted == true && y.CreatorID == userID)will only get the friendships in one direction. meaning if someone else created the friend request and your user...
9 Jun 2014 by Prasaad SJ
I m using EntityFramework to get the data from the DB. consider I have a tableBuyer{ guid id, datetime date, guid userid references user(id)}user{ guid id, string name}consider the above class as table in DB.I want to return user name in buyer list....
10 Jun 2014 by goathik
I had the same problems concerning the use of includes slowing down my linq performance.To solve that problem I had use "select new" on linq to manually populate the properties I needed (User.Name, on your case) into a partial class having the same name (Buyer) and namespace of the class in...
10 Sep 2014 by misaqyrn9677
hii want insert a new record by language lambda in web form my data base is sql server 2012 and use in asp.net c#(web) please help me
14 Sep 2014 by Simba Mukodzani
I have a piece of code like the following....Delegate Function CreateObject(Of I)(Object context) As IClass Container Property ReadOnly ObjectType() As TypeEnd ClassClass Container(of I) Inherits Container Property ReadOnly Creator() As CreateObject(Of I)End...
16 Oct 2014 by GateKeeper22
I am have a problem with Dynamically generated compared to a regular lambda expression in code. Below is the code that I use to generate a dynamic lambda.Dynamic Lambdavar parameterExp = Expression.Parameter(typeof(T), "x");var propertyExp = Expression.Property(parameterExp,...
1 Nov 2014 by Member 11180545
helloHow do I repeat phrases when loading data from the database don't show to control of drop down listplz help memy code is var JensKakhat = db.ItemProducts.Where(c => c.ForProductId == DdlProduct.SelectedValue.ToString()).ToList();int count3 = JensKakhat.Count();if (count3
1 Nov 2014 by DamithSL
var result = JensKakhat.GroupBy(g => g.Id) .Select(g => g.First()) .ToList();PnlTypePaper.Visible = result.Any(); DdlTypePaper.DataSource = result;DdlTypePaper.DataTextField = "ItemNine";DdlTypePaper.DataValueField =...
13 Dec 2014 by mukesh mourya
DataClasses1DataContext dm= new DataClasses1DataContext();foreach (var cln in SelectedList) { var result = dm.Challan_Totals.Where(x => x.Challan_No == cln) .Join(dm.Challans, ct =>...
26 Jan 2015 by Abhinav S
You can debug and check exactly where the error occurred and what caused it.That would be the easiest way to find the error.
29 Jan 2015 by Member 11413084
I have two tables (TestSets and TestSetMembers) with a many to many relationship defined in an Entity Framework. In other words, one TestSet can have one or more TestSetMembers belonging to it. And one TestSetMember can belong to one or more TestSets.I can not understand why the...
29 Jan 2015 by Dave Kreskowiak
You seem to not know what the All extension method does.It tests every element in an IEnumerable to see if they all pass the specified test. If they all do, then the return value is true. If not, then false.Since I doubt every element in your set .Contains(ts), the result of the LINQ...
8 Apr 2015 by Maciej Los
First of all, please read my comment to the question.Here is an idea:101 LINQ Samples[^]How to: Group Query Results (C# Programming Guide)[^]How to Use LINQ GroupBy[^]
13 Apr 2015 by bkashani
Hello I have this sql command Could you help me How can I write this with lambda expression?Select A.*from Tablename A inner join (select address,state from Tablename group by address,state having...
13 Apr 2015 by Maciej Los
Try this:var qry = TableA.AsEnumerable() .GroupBy(a=>new{a.address, a.state}) .Where(grp.Count()>1) .Select(d=>new{address=d.Key.address, state=d.Key.state});
2 May 2015 by fahd951
Hi there,First thank you to visit my post ..I just start my way with Linq so I'm sorry if it's stupid question :(I have this ERD design ..http://www.m5zn.com/newuploads/2015/05/02/jpg//6fe7a5567905df0.jpg[^]also I wrote this...
28 May 2015 by Member 11581003
I have a table that stores Referral details - it includes fields like Referral Type, Referral Date, OffenderID, OfficerID etc.) And obviously some Offenders are referred more than once (multiple times) and likewise, OfficerID also repeats in the table as many offenders are referred by the same...
28 May 2015 by Sascha Lefèvre
To give you a fully working query I would have to know how your Offender- and Officer-Tables/Entities look like. So I'll make a good guess here instead and to illustrate I include all the code I wrote to test it. You obviously can discard everything except the query at the bottom. I assume...
4 Jul 2015 by deepakdynamite
I have list of information with following fields:Project State Title ABC Resolved Title1 ABC Pending Title2 DEF Archived Title3 DEF Resolved Title4 DEF Committed Title5 DEF Active Title6I want...
9 Aug 2015 by Mehdi Gholam
Start here : http://www.c-sharpcorner.com/UploadFile/0f68f2/programmatically-binding-datasource-to-combobox-in-multiple/[^]
20 Aug 2015 by NJ44
Hi All,I need your help in writing a linq query (with lambda expressions) for the following scenario.AIM: I am receiving a response from a web API, which is in the following structure: Response contains 4 levels of nesting(of collections): WebAPIResponse:CycleSummary(n) ->...
20 Aug 2015 by DamithSL
try as below IOPCallTypeModel[] iOPBillingPeriods =cycleSummaries.Select(x=> new IOPCallTypeModel(){ StartDate =//create and set VoiceZone.StartDate from x.StartDate, // do the same for rest of the properties... }).ToArray();
13 Nov 2015 by Maniraj.M
Hi all,i having a code like this and iam binding that string value to dropdownlist. string test = ds.Tables[0].AsEnumerable().Where(x => x.Field("Id") == lbl.Text).Select(z => z.Field("Description")).ToString();Drpdwn.Items.Add(test);but when execution it binds like this, ...
11 Nov 2015 by Krunal Rohit
Loops through the collection and add it to the dropdown items.var items = ds.Tables[0].AsEnumerable().Where(x => x.Field("Id") == lbl.Text).Select(z => z.Field("Description")).ToList();foreach(var i in items){ Drpdwn.Items.Add(i.ToString());}-KR
17 Jan 2016 by vacho2
I would like to propagate entity framework include properties across architecture.1. Starting at the service layer where these include properties come as an argumentIEnumerable GetUsers(user => user.Classes);2. The method getUsers must translate this expressions from ViewModel to...
21 Mar 2016 by Cyrus_Vivek
Hi,I am not sure if my expression is correctly. Correct me if anything syntax is wrong. This has to filter by PipelineName = Utility (This following code is not filtering by utility)I am expecting it should pull only for those utility we are passing as a parameter.I can understand it...
16 Aug 2016 by super_user
I create sql query now i try to convert this in linq with lamda expressionselect Catg_type.Catg_type,Program_type.Prog_name ,Year_info.year,COUNT(Std_info.catg_id) as total_students from Std_info inner join Catg_type on Std_info.Catg_id=Catg_type.Catg_idINNER join Program_type on...
16 Jun 2017 by komakommander
Hi everyone,i am banging my head on the following task:I have an AzureFunction that uses a ServiceBus-Trigger like so:{ "bindings": [ { "name": "myQueueItem", "type": "serviceBusTrigger", "direction": "in", "connection": "MyConnection", ...
15 Jul 2016 by Troy Bryant
Hi -I'm looking to rewrite this query in linq and literally have no idea. In my application I have strongly typed view models so dont know if using annomous types as a few of the articles have stated.Here is the sql : select...
15 Jul 2016 by Vignesh Mani
var queryNestedGroups = from student in students group student by student.Year into newGroup1 from newGroup2 in (from student in newGroup1 group student by student.LastName) group newGroup2 by newGroup1.Key;
2 Aug 2016 by Maniraj.M
Hi all, This is my function i want select particular column from dataset using lambda expression and add into var temp to return that.I am not getting string format but i am getting object format as System.Collections.Generic.List`1[System.String].Why this is happening?Is my approach...