{"id":20005609,"url":"https://github.com/jorgecupi/linq_azurefunctions","last_synced_at":"2026-05-14T02:35:03.322Z","repository":{"id":69266814,"uuid":"106427453","full_name":"JorgeCupi/LINQ_AzureFunctions","owner":"JorgeCupi","description":"This is a short tutorial on how to use .NET Language Integrated Query (LINQ) properly in Azure Functions","archived":false,"fork":false,"pushed_at":"2017-10-14T03:16:16.000Z","size":758,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-02T00:49:03.056Z","etag":null,"topics":["azure-functions","database","linq","linq-documentation","sql-database"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JorgeCupi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-10T14:21:36.000Z","updated_at":"2023-07-25T04:22:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"c937892f-f3c2-4972-991e-76a1b8707dec","html_url":"https://github.com/JorgeCupi/LINQ_AzureFunctions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JorgeCupi/LINQ_AzureFunctions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JorgeCupi%2FLINQ_AzureFunctions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JorgeCupi%2FLINQ_AzureFunctions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JorgeCupi%2FLINQ_AzureFunctions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JorgeCupi%2FLINQ_AzureFunctions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JorgeCupi","download_url":"https://codeload.github.com/JorgeCupi/LINQ_AzureFunctions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JorgeCupi%2FLINQ_AzureFunctions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33008192,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure-functions","database","linq","linq-documentation","sql-database"],"created_at":"2024-11-13T05:41:28.716Z","updated_at":"2026-05-14T02:35:03.307Z","avatar_url":"https://github.com/JorgeCupi.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Using LINQ in Azure Functions\nThis is a short tutorial on how to use LINQ properly in Azure Functions. If you want to skip the explanation part of the repo and just look at the code then all the examples are in the /code folder.\n\n\u003e LEARN MORE. If you are not familiar with Azure Functions I recommend you read the \u003ca href=\"https://docs.microsoft.com/en-us/azure/azure-functions/\"\u003eofficial documentation here\u003c/a\u003e. There are amazing samples and guides to start from zero. You will also need an Azure account. If you do not have one, you can \u003ca href=\"https://azure.microsoft.com/en-us/free/?v=17.39a\"\u003estart for free here\u003c/a\u003e.\n\n## What is LINQ? ##\n\u003ci\u003eLanguage-Integrated Query (LINQ) is the name for a set of technologies based on the integration of query capabilities directly into the C# language. Traditionally, queries against data are expressed as simple strings without type checking at compile time or IntelliSense support. Furthermore, you have to learn a different query language for each type of data source: SQL databases, XML documents, various Web services, and so on. With LINQ, a query is a first-class language construct, just like classes, methods, events.\u003c/i\u003e - \u003ca href=\"https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/\"\u003eOfficial LINQ documentation\u003c/a\u003e\n\nBasically, what LINQ allows us is to make these type of queries:\n\n```csharp\n\n            int n = int.Parse(Console.ReadLine());\n\n\t    Random random = new Random();\n            int[] temperature = new int[n];\n\n            for (int i = 0; i \u003c n; i++)\n            temperature[i] = random.Next(1, 100);\n\t\t\n            // Query syntax\n            IEnumerable\u003cint\u003e results =  from x \n                                        in temperature \n                                        where x \u003e= 50 \n                                        select x;\n\n            // Method syntax\n            IEnumerable\u003cint\u003e results2 = temperature.Where(num =\u003e num \u003c= 50);\n\n            Console.WriteLine(\"Results: \");\n            foreach (int x in results)\n                Console.WriteLine(x);\n\n            Console.WriteLine(\"Results 2: \");\n            foreach (int x in results2)\n                 Console.WriteLine(x);\n  \n\n```\nAnd we can query not just arrays or lists but also objects in general, XML files and SQL databases as we wll do later.\n\nAs you can see there are two types of querying styles: Query syntax and Method syntax. You can learn about their differences, pros and cons at the \u003ca href=\"https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/standard-query-operators-overview\"\u003eLINQ Documentation\u003c/a\u003e. In this article we will mostly used query syntax when querying our database.\n\nIn this repo you will find your ways to do basic operations to a SQL Server Database using LINQ in Azure Functions, we will cover how to:\n- Add a new row to a table\n- Update a row\n- Delete a row\n- Querying single and multiple tables using LINQ query syntax\n\n## Creating an Azure Function App ##\nAfter logging in to our Azure Account we click the 'New' button on the upper left side on the page and type \u003ci\u003e'function'\u003c/i\u003e in the search bar:\n![\"Image 1. Azure Portal\"](images/functions-1.png)\n\n\nOnce we click the 'Create' button after selecting 'Function App' in the previous menu we will find the next form in which will fill some basic information regarding our Function App\n\n![\"Image 2. Filling the info for our Azure Function \"](images/functions-2.png)\n\n## Creating our functions ##\nA Function App in Azure can host multiple Functions so we will leverage this to have a single function for each operation we will work on at this repo.\n\n### Adding our SQL Server connection string ###\nBefore starting to use LINQ we will add out database connection string to our Function App: We have to click on 'Application Settings' which is located under the 'Configured features' sub menu in our recently created Function App:\n\n![\"Image 3. Adding a connection string to our Function App](images/functions-3.png)\n\nOnce there we find a sub menu called 'Connection strings'. We create a new value by pasting our database connection string and giving a name to the connection:\n![\"Image 4. Setting  new connection string in the App Settings page\"](images/functions-4.png)\n\n\u003e TIP. Remember to change add your password and username to your connection string. Also, select your database type at the right side of the connection string value. For this repo we're working with SQL Azure.\n\n### Creating our first function ###\nAzure Functions have many ways to interact with users including Triggers, Inputs and Outputs form multiple sources. We can:\n- Trigger a function using an EventHub,\n- Use blob storage as an input,\n- Write directly to a Cosmos DB table,\n- among other scenarios.\n\nFor this specific repo we will use a manual trigger for our Functions. That means, the function will be activated only when we push a \"Run\" button on the function site\n\nTo create a new function we just click the '+' button in our Functions menu. Once there we select 'Custom function' below the 'Get started on your own' sub title:\n\n![Image 5. Creating our first function](images/functions-5.png)\n\nHere we will look for the ManualTrigger template written in C#, give it a name and click the 'Create' button:\n![Image 6. Selecting a Manual trigger for our function](images/functions-6.png)\n\n\u003e NOTE. While a manual trigger might not be a real live scenario,it is a good enough scenario for what we want to achieve which is using LINQ to query a database.\n\n### Mapping our database tables to C# classes ###\nWe can do this manually, for each table we can create a class with a 'TableAttribute' indicating the name of such table and a 'ColumnAttribute' for each attribute:\n\n```csharp\n[Table(Name = \"SalesLT.Product\")]\npublic class SalesLT_Product\n{\n    [Column(Name=\"Name\")]\n    public string Name {get;set;}\n}\n```\n\u003e LEARN MORE. You can find regarding \u003ca href=\"https://docs.microsoft.com/en-us/dotnet/api/system.data.linq.mapping.columnattribute?view=netframework-4.7\"\u003eColumnAttribute\u003c/a\u003e and \u003ca href=\"https://docs.microsoft.com/en-us/dotnet/api/system.data.linq.mapping.tableattribute?view=netframework-4.7\"\u003eTableAttribute\u003c/a\u003e on their respective documentation. \n\nHowever there will be times when our database is composed of multiple tables, probably dozens of them, each of one with other dozens of attributes. In those times it will probably be better to use mapping tools to automate this process. On this ocassion we will use a command called \u003ca hred=\"https://docs.microsoft.com/en-us/dotnet/framework/tools/sqlmetal-exe-code-generation-tool\"\u003eSqlMetal.exe\u003c/a\u003e, but there are other ways to do it, find \u003ca href=\"https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/linq/how-to-generate-the-object-model-in-visual-basic-or-csharp\"\u003emore info here\u003c/a\u003e.\n\n#### Using SqlMetal.exe ####\nIt is fairly easy to use SqlMetal.exe. If we have installed Visual Studio on our machines, we already have to tool at our PCs, if not we just have to download the \u003ca href=\"https://www.microsoft.com/en-us/download/details.aspx?id=8279\"\u003eWindows SDK from here\u003c/a\u003e\nNow let's open a Developer Command Prompt and type the next command\n```\nsqlmetal /code:{FileNameOfYourGeneratedCode.cs} /conn:\"{YourDataBaseConnectionString}\"\n```\n\nThis command will result into a new CS file containing your new classes that have mapped your entire database.\n\n\u003e TIP. You do not need to map ALL your database if you only want to query a couple of tables as long as such tables are not related to other tables that will not be mapped.\n\n#### Uploading a file to your Function App ####\nNow that we have our CS file with our mapped tables into classes we need to upload said file to our Azure Function App. This is easier done than said:\nWe go to our Function App Settings page by clickin on the App name, and then click on Advanced Tools (Kudu) located in the lower center part of the page:\n![\"Image 7. Uploading a file to Function Apps\"](images/functions-7.png)\n\nOnce there we go to the 'Debug Console' tab and select 'CMD':\n![\"Image 8. Going to the Debug Console site\"](images/functions-8.png)\n\nWe now have to navigate to the directory of our function. The location will be something similar to:\n```\nD:\\home\\site\\wwwroot\\{NameOfOurFunction}\n```\n\nand once in our Function folder we drag \u0026 drop our CS file (in our example the file name is 'mappedClasses.cs':\n![\"Image 9. Uploading a file to Function Apps\"](images/functions-9.png)\n\n### Exercise 1: Querying a single table ###\nWith our mapped table and connection string in place we are ready to use LINQ to query our database:\n\nFirst we need to add a reference to System.XML.Lin on our mappedClasses.cs file before our 'Using' statements:\n\n```javascript\n#r \"System.XML.Linq\"\n```\n\nThen, at our run.csx file we will add some references to libraries and to our mappedClasses.cs file as well:\n\n```javascript\n#r \"System.Data.Linq\"\n#r \"System.Data\"\n#r \"System.Configuration\"\n#load \"mappedClasses.cs\"\n```\n\nNow let's code:\n\nFirst we need to acquire our connection string we saved in the App Settings moments ago, we can do this by writing the next line:\n\n```csharp\nstring connString = ConfigurationManager.ConnectionStrings[\"connString\"].ConnectionString;\n```\n\u003e NOTE. Remember we named our connection string 'connString' in the App Settings.\n\nNow that we have the connection string is time to connect to our database using the DataContext class and using its GetTable method:\n\n```csharp\nDataContext db = new DataContext(connString);\nTable\u003cSalesLT_Product\u003e products = db.GetTable\u003cSalesLT_Product\u003e();\n```\n\nQuerying time, as mentioned before we will use the Query syntax type a simple query would look like this:\n```csharp\n    IQueryable\u003cSalesLT_Product\u003e results = from product \n                                        in products \n                                        where product.Color == \"Black\"\n                                        select product;\n\n```\nThis query will get us the same outcome as the next T-SQL query:\n```sql\nselect * from SalesLT.Product where Color = \"Black\"\n```\n\n\u003eTIP. The variable 'product' could have any name as it is only a nickname for the values that will be retrieved. \n\nHow can we look at the results returned? Simply by iterating over our 'results' variable:\n```csharp\nforeach (SalesLT_Product item in results)\n{\n    // Do something here\n}\n```\n\nThe complete code will look like this:\n\n```csharp\npublic static void Run(string input, TraceWriter log)\n{\n    string connString = ConfigurationManagver.ConnectionStrings[\"connString\"].ConnectionString;\n    \n    DataContext db = new DataContext(connString);\n    Table\u003cSalesLT_Product\u003e products = db.GetTable\u003cSalesLT_Product\u003e();\n\n    IQueryable\u003cSalesLT_Product\u003e results = from product in products select product;\n\n    int count =1; \n    foreach (SalesLT_Product item in results)\n    {\n        log.Info($\"{count}-{item.Name}\");\n        count++;\n    }\n    log.Info($\"You have a total of {results.Count()} products\");\n}\n```\n\u003eoutput:\n```\n\n2017-10-10T19:53:34.752 1-HL Road Frame - Black, 58\n2017-10-10T19:53:34.752 2-HL Road Frame - Red, 58\n2017-10-10T19:53:34.752 3-Sport-100 Helmet, Red\n2017-10-10T19:53:34.752 4-Sport-100 Helmet, Black\n2017-10-10T19:53:34.752 5-Mountain Bike Socks, M\n2017-10-10T19:53:34.752 6-Mountain Bike Socks, L\n2017-10-10T19:53:34.752 7-Sport-100 Helmet, Blue\n2017-10-10T19:53:34.752 8-AWC Logo Cap\n2017-10-10T19:53:34.752 9-Long-Sleeve Logo Jersey, S\n2017-10-10T19:53:34.752 10-Long-Sleeve Logo Jersey, M\n... more\n```\n\n### Exercise 2: Querying multiple tables ###\nQuerying a single table with LINQ was easy and probably had the same difficulty as doing it with T-SQL. But it is when we need to join tables that LINQ becomes powerful.\nWhat T-SQL query would we have to use if we wanted to check all products that are 'Mountain Frames' and 'Black'? \n```sql\nSELECT SalesLT.Product.Name, SalesLT.Product.Color, SalesLT.ProductCategory.Name\nFROM SalesLT.Product JOIN SalesLT.ProductCategory\nON SalesLT.Product.ProductCategoryID=SalesLT.ProductCategory.ProductCategoryID\nWHERE SalesLT.Product.Color = 'Black' AND SalesLT.ProductCategory.Name = 'Mountain Frames'\n```\n\nWhile with LINQ it would be as simple as:\n```csharp\nIQueryable\u003cSalesLT_Product\u003eresults = \n    from product \n    in products \n    where (product.Color == \"Black\") \n    \u0026\u0026 (product.SalesLT_ProductCategory.Name == \"Mountain Frames\")\n    select product.Name,product.Color,product.SalesLT_ProductCategory.Name;\n```\n\nEven if we wanted to define a new class to receive just those 3 attributes: Name, Color and Category name we just need to define a new class:\n\n```csharp\npublic class SimpleProduct\n{\n    public string name{get;set;}\n    public string color{get;set;}\n    public string category{get;set;}\n}\n```\n\nAnd modify the LINQ query to return an IQueryable object of our new 'SimpleProduct' class:\n```csharp\nIQueryable\u003cSimpleProduct\u003e results = \n    from product \n    in products \n    where (product.Color == \"Black\") \n    \u0026\u0026 (product.SalesLT_ProductCategory.Name == \"Mountain Frames\")\n    select new SimpleProduct\n    {\n        name = product.Name,\n        color = product.Color,\n        category = product.SalesLT_ProductCategory.Name\n    };\n```\nThe benefits? Not only we do not need to 'join' our mapped tables but we also have a more readable query using LINQ.\n\nWe will have to upload mappedClassed again for our new second function and add the previously used references. The complete code for the second example looks like this:\n```csharp\n#r \"System.Data.Linq\"\n#r \"System.Data\"\n#r \"System.Configuration\"\n#load \"mappedClasses.cs\"\n\nusing System.Configuration;\nusing System.Data.Linq;\nusing System.Data.Linq.Mapping;\nusing System.Linq;\n\n\npublic static void Run(string input, TraceWriter log)\n{\n    string connString = ConfigurationManager.ConnectionStrings[\"connString\"].ConnectionString;\n    \n    DataContext db = new DataContext(connString);\n    Table\u003cSalesLT_Product\u003e products = db.GetTable\u003cSalesLT_Product\u003e();\n\n    IQueryable\u003cSimpleProduct\u003e results = \n    from product \n    in products \n    where (product.Color == \"Black\") \n    \u0026\u0026 (product.SalesLT_ProductCategory.Name == \"Mountain Frames\")\n    select new SimpleProduct\n    {\n        name = product.Name,\n        color = product.Color,\n        category = product.SalesLT_ProductCategory.Name\n    };\n\n    int count =1; \n    foreach (SimpleProduct item in results)\n    {\n        log.Info($\"{count} - {item.name} - {item.color} - {item.category}\");\n        count++;\n    }\n    log.Info($\"{results.Count()} products\");\n}\n\npublic class SimpleProduct\n{\n    public string name{get;set;}\n    public string color{get;set;}\n    public string category{get;set;}\n}\n```\n\n### Exercise 3: Inserting a new row ###\nFor this excercise, instead of our generic DataContext we'll use the one that was created with the mapping SqlMetal tool:\n```csharp\n[global::System.Data.Linq.Mapping.DatabaseAttribute(Name=\"functionsdb\")]\npublic partial class Functionsdb : DataContext\n{\n\t\n\tprivate static MappingSource mappingSource = new AttributeMappingSource();\n\t\n\tpartial void OnCreated();\n\t\n\tpublic Functionsdb(string connection) : \n\t\t\tbase(connection, mappingSource)\n\t{\n\t\tOnCreated();\n\t}\n    \n    // More auto generated code...\n}\n```\nSo in our Run.csx class, instead of:\n\n```console\nDataContext db = new DataContext(connString);\n```\nwe will use:\n\n```console\nFunctionsdb db = new Functionsdb(connString);\n```\n\nWhy will we use this new class that inheritates from DataContext anyway?\nMostly because we can modify this new class, or in our specific case, we can leverare the already generated 'Table' objects that the 'Functionsdb' class contains:\n```csharp\npublic Table\u003cSalesLT_Address\u003e SalesLT_Address\n{\n    get\n    {\n        return this.GetTable\u003cSalesLT_Address\u003e();\n    }\n}\n\npublic Table\u003cSalesLT_Customer\u003e SalesLT_Customer\n{\n    get\n    {\n        return this.GetTable\u003cSalesLT_Customer\u003e();\n    }\n}\n\n// ... More generated objects\n```\n\nHaving this tools. Adding a new row to is as easy as creating a new object and adding it to the its specific table in the datacontext:\n\n```csharp\nSalesLT_Address address = new SalesLT_Address{\n    AddressLine1 = \"Cl 92 #11 51\",\n    City = \"Bogota\",\n    StateProvince = \"Bogota D.C.\",\n    CountryRegion = \"Colombia\",\n    PostalCode = \"110111\",\n    Rowguid = Guid.NewGuid(),\n    ModifiedDate = DateTime.Now\n};\n\ndb.SalesLT_Address.InsertOnSubmit(address);\ndb.SubmitChanges();\n```\n\nThe complete code for the Add function will look like this:\n```csharp\n#r \"System.Data.Linq\"\n#r \"System.Data\"\n#r \"System.Configuration\"\n#load \"mappedClasses.cs\"\n\nusing System.Configuration;\nusing System.Data.Linq;\nusing System.Data.Linq.Mapping;\nusing System.Linq;\n\n\npublic static void Run(string input, TraceWriter log)\n{\n    string connString = ConfigurationManager.ConnectionStrings[\"connString\"].ConnectionString;\n    \n    Functionsdb db = new Functionsdb(connString);\n\n    SalesLT_Address address = new SalesLT_Address{\n        AddressLine1 = \"Cl 92 #11 51\",\n        City = \"Bogota\",\n        StateProvince = \"Bogota D.C.\",\n        CountryRegion = \"Colombia\",\n        PostalCode = \"110111\",\n        Rowguid = Guid.NewGuid(),\n        ModifiedDate = DateTime.Now\n    };\n\n    try\n    {\n        db.SalesLT_Address.InsertOnSubmit(address);\n        db.SubmitChanges();\n        log.Info($\"Your have successfully inserted a new row to your table.\");\n    }\n    catch\n    {\n        log.Info($\"Something went wrong. Please try again.\");\n    } \n}\n```\n\u003eOutput\n```console\n2017-10-11T20:33:11.932 Function started (Id=bf656aea-f7d7-4258-917e-33b95c4b10ad)\n\n2017-10-11T20:33:12.072 Your have successfully inserted a new row to your table.\n\n2017-10-11T20:33:12.072 Function completed (Success, Id=bf656aea-f7d7-4258-917e-33b95c4b10ad, Duration=145ms)\n```\n\n### Exercise 4: Updating a row ###\nUpdating a row is easy as well. We just have to:\n- Retrieve an object from our database with the ID of the row we want to update\n- Modify the object\n- Submit changes using the data context\n\n```csharp\nSalesLT_Address address = (from c in db.SalesLT_Address\n                 where c.AddressID == 11387\n                 select c).First();\n\naddress.AddressLine2 = \"Chapinero\";\ndb.SubmitChanges();\n```\n\nThat's it! The whole code of the function will look like this:\n```csharp\n#r \"System.Data.Linq\"\n#r \"System.Data\"\n#r \"System.Configuration\"\n#load \"mappedClasses.cs\"\n\nusing System.Configuration;\nusing System.Data.Linq;\nusing System.Data.Linq.Mapping;\nusing System.Linq;\n\n\npublic static void Run(string input, TraceWriter log)\n{\n    string connString = ConfigurationManager.ConnectionStrings[\"connString\"].ConnectionString;\n    \n    Functionsdb db = new Functionsdb(connString);\n\n    SalesLT_Address address = (from c in db.SalesLT_Address\n                 where c.AddressID == 11387\n                 select c).First();\n\n    address.AddressLine2 = \"Chapinero\";\n\n    try\n    {\n        db.SubmitChanges();\n        log.Info($\"Your have successfully updated your row.\");\n    }\n    catch\n    {\n        log.Info($\"Something went wrong. Please try again.\");\n    } \n}\n```\n### Exercise 5: Deleting a row ###\nDeleting a row is similar to editing one:\n- We need to retrieve the row\n- Use the 'deleteOnSubmit' method\n- Commit the changes using the data context\n```csharp\nSalesLT_Address address = (from c in db.SalesLT_Address\n                 where c.AddressID == 11389\n                 select c).First();\n\ndb.SalesLT_Address.DeleteOnSubmit(address);\ndb.SubmitChanges();\n```\nThe complete function has only a few lines of code:\n```csharp\n#r \"System.Data.Linq\"\n#r \"System.Data\"\n#r \"System.Configuration\"\n#load \"mappedClasses.cs\"\n\nusing System.Configuration;\nusing System.Data.Linq;\nusing System.Data.Linq.Mapping;\nusing System.Linq;\n\n\npublic static void Run(string input, TraceWriter log)\n{\n    string connString = ConfigurationManager.ConnectionStrings[\"connString\"].ConnectionString;\n    \n    Functionsdb db = new Functionsdb(connString);\n\n    SalesLT_Address address = (from c in db.SalesLT_Address\n                 where c.AddressID == 11389\n                 select c).First();\n\n    try\n    {\n        db.SalesLT_Address.DeleteOnSubmit(address);\n        db.SubmitChanges();\n        log.Info($\"Your have successfully deleted your row.\");\n    }\n    catch\n    {\n        log.Info($\"Something went wrong. Please try again.\");\n    } \n    \n}\n```\n## Conclusion ##\nLINQ and Azure Functions combined can be powerful and easy to use tools  when:\n- We are running a legacy App with older versions of .NET framework that do not support LINQ but we still want to easily access our database.\n- We are in a Internet of Things (IoT) scenario with devices that just need to add data quick and easily to our database and can only communicate to the internet via HTTP requests\n- We do not want to mix database logic with application logic on our web application\n- ... among other scenarios you could think of.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorgecupi%2Flinq_azurefunctions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjorgecupi%2Flinq_azurefunctions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorgecupi%2Flinq_azurefunctions/lists"}