teleren/devto huggingface dataset:
EntityFramework Query Tagging
Tags: entityframeworkcore, efcore, aspnetcore, query
Published: 2022-07-03 23:36:36

---
title: EntityFramework Query Tagging
published: true
date: 2020-09-07 23:22:23 UTC
tags: entityframeworkcore,efcore,aspnetcore,query
canonical_url: 
---

![](https://cdn-images-1.medium.com/max/1024/1*orAwJ3m61dWMbF_0rnkPyQ.png)

EntityFramework Core 2.2 ile birlikte hayatımıza giren query tagging özelliğini size anlatmaya çalışacağım.

Özellikle EF ile yazılan uygulamalarda, karmaşık LINQ sorguları ile yazdığımız sql çıktılarının takibi, karmaşıklığı ve performans sorunlarını hepimiz biliyoruz. Bu gibi durumlarda çıktıları kontrol etmemiz, özellikle EF’nin oluşturduğu sorguların execution planlarını ve performans metriklerini takip etmemiz zor olabiliyor.

> Alternatif Çözüm olarak APM ürünlerini kullanabilirsiniz.

Query Tagging, hem database yönetimi hem de log’lama sistemleri için sorgularımızı etiketleyerek, hızlıca erişebileceğimiz bir özelliktir.

Sorgularınızı yazarken; ne amaçla yapıldığını / yazıldığını belirten bir işaretleme (tagging) yapıyoruz.

Örneğin

- GetFirst50Products — Product tablosunda ilk 50 kaydı getiren sorgu
- GetAllUserRoles — Kullanıcı rollerinin tümünün çekildiği sorgu

Bunu yapabilmemiz için aşağıdaki gibi TagWith extension fonksiyonunu kullanabilirsiniz.

```
var first50Item = dataContext
    .Products
    **.TagWith("Get First 50 Item")**
    .OrderBy(p => p.CreateDate)
    .Take(50).ToList();
```

Sorgunun çıktısı ise bu şekilde olacaktır.

![](https://cdn-images-1.medium.com/max/1024/1*cni8QUeyJiyaOjrjpKaPxQ.png)

Sql Server üzerinde son çalıştırdığınız sql dizisine erişmek için aşağıdaki sorguyu kullanabilirsiniz.

```
SELECT deqs.last_execution_time AS [Time], dest.text AS [Query], dest.*
FROM sys.dm_exec_query_stats AS deqs
         CROSS APPLY sys._dm\_exec\_sql\_text_(deqs.sql_handle) AS dest
where text like '%-- Get First 50 Item%'
ORDER BY deqs.last_execution_time DESC
```

![](https://cdn-images-1.medium.com/max/1024/1*Oz5SPE_KB2bPEU9ZhZSDJg.png)

İlgili yazının uygulanışına aşağıdaki linkten erişebilirsiniz.

[cagdaskarademir/efcore-query-tagging](https://github.com/cagdaskarademir/efcore-query-tagging)

Ref : [https://post.cagdaskarademir.com/2020/entityframework-query-tagging](https://post.cagdaskarademir.com/2020/entityframework-query-tagging)
Need help? Looking for homies? Join our Web Dev Chat with Like-minded Individuals. Everyone is welcome.
Tags: javascript, webdev, beginners, react
Published: 2020-09-07 23:19:59

Hiya!

I've created a Discord servers for like-minded developers to commune. You can join [here](https://discord.gg/HhvVybh).

> WorldWideWeb is a new Discord server for humans who...
> 🐥 Want to find like-minded individuals with similar interests in web development.
> 🦄 Need help on their web-related projects.
> 🐸 Seek to hire talented developers, or seek to be hired for their talents.
> 🧬 Want a place to share, talk about, and find information on web-related projects.

Web developers of all kinds are invited—wether you're a pro, a beginner, or simply are interested in learning a thing or 2, you're welcome to join us.

Personally, my focus is in JavaScript based technology, so we currently have channels for a bunch of JavaScript frameworks, such as React.js and Electron.js. We've also created channels for most of the common languages, such as CSS, HTML, PHP, Python, and more.

We're actively developing this server, so we're open to creating new web-related channels desired by users.

We're also just starting off, so if anyone is interested in becoming a contributor (helper, administrator, etc.), we could surely use some help.

I hope this grows into an inviting place for web developers of all trades.

Seeya there! :)

[Join](https://discord.gg/HhvVybh)
https://discord.gg/HhvVybh

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/c6u4s6lme53zacuotj6a.png)
Leetcode 3. Longest Substring Without Repeating Characters

Tags: leetcode, slidingwindow, javascript, algorithms
Published: 2020-09-07 22:44:18

Given a string s, find the length of the longest substring without repeating characters.

 

###Example 1:
```
Input: s = "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.
```
###Example 2:
```
Input: s = "bbbbb"
Output: 1
Explanation: The answer is "b", with the length of 1.
```
###Example 3:
```
Input: s = "pwwkew"
Output: 3
Explanation: The answer is "wke", with the length of 3.
Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.
```
###Example 4:
```
Input: s = ""
Output: 0
```
###Solution
Time complexity : O(n)

```javascript
var lengthOfLongestSubstring = function(s) {
    let start = 0;
    let output = 0;
    let map = {}
    // In each loop currentLetter gets saved in the map
    // with its index+1 as the value
    for(let end = 0; end < s.length; end++) {
        const currentLetter = s.charAt(end);
       // If we have encountered currentLetter before,
       // we move the start pointer to the value
       // of currentLetter in the map or 
       // keep the start pointer the same depending 
       // on which value is greater
        if (map[currentLetter]!==undefined) {
          // This prevents the start pointer from decreasing
          start = Math.max(map[currentLetter], start);
        }
        output = Math.max(output, end - start + 1);
        // Add 1 to the index to prevent the currentLetter
        // from being included in the window when
        // currentLetter is encountered again
        map[currentLetter]=end+1;
    }
    return output;
};
```
Resume Workshop With Google
Tags: google, workshop, resume
Published: 2020-09-07 22:34:26

Are you a university student submitting applications for internships and full-time opportunities this semester?

It is recommended to have an updated resume on hand so you can apply your knowledge in real time!

Join Google for this resume workshop to learn tips on how to format, structure, and create detailed content for your resume.

Register here :
https://careersonair.withgoogle.com/events/resume-workshop

Links :
https://techdevelopers-td.blogspot.com/2020/09/resume-workshop-with-google.html

https://dev.to/fady_nabil10/resume-workshop-with-google-562

https://medium.com/@fady.nabil/resume-workshop-with-google-e386adfa34a

#google #resume #workshop #university #student #application #internships #opportunities #apply

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mbnx1xq40ua2fol7hlgz.jpg)
My #100DOC - Day 12
Tags: challenge, 100daysofcode, log
Published: 2020-09-07 22:27:46

### Day 12: September 7, 2020

#### **Today's Progress**: 
1. **[Continued with The Complete JavaScript Course](https://github.com/pablohs1986/javaScriptCompleteCourse2020_Schmedtmann)** (1h):<br>In today's lesson I review DRY principle and its importance. I also learned what is and when use a state variable.
    
#### **What I learned**: 
* The importance of DRY.
* What is and whem use a state variable.

#### **Total time**:
1h.
Elon Musk demo of Neuralink device
Tags: future, news, neuralink
Published: 2020-09-07 22:16:21

Elon Musk's announcement of the Neuralink chip that will frighteningly change the future:

- The chip will be installed in the brain. Nobody will know whether you have a chip or not. Elon said, "I may be the compiler of the chip now and no one will know that."

A chip reads everything inside your brain, does all the jobs, predicts, plans and solves problems for you.

- The place where the chip is implanted allows it to treat many problems such as vision, hearing, memory, psychological problems, addiction, and even autism.

- You can communicate with the chip through your electronic devices such as your phone, and a Tesla car.

- It will have a permanent development of the slide, for example there will be an upcoming development, through which you will be able to cancel any painful feelings such as feeling pain and sadness.

- You can control your memories and even your dreams and store them in the form of files. If you feel upset, you can play the memory that makes you happy.

- There is no way for your data to be hacked through the chip.

There will be a thing called "superhuman capabilities", through which the human being will be stronger than ever before. You will see from the farthest range, your hearing will be stronger, you can even cancel your feelings and turn them on.

The slide has been manufactured, approved, and tested, and human clinical trials will start soon.

This is said in a conference before the whole world. This conference is an hour and 13 minutes
https://www.youtube.com/watch?v=DVvmgjBL74w

Resoures :
https://techdevelopers-td.blogspot.com/2020/09/elon-musk-demo-of-neuralink-device.html

https://www.theverge.com/2020/8/26/21402240/neuralink-august-2020-event-brain-machine-interface-working-demonstration?fbclid=IwAR387MfgTLrAMA6tZbhK7325WHrIkYufWUOodrCRr81DQbg8MU_bjl1AV_Q

https://www.businessinsider.com/elon-musk-neuralink-brain-chip-put-in-human-within-year-2020-5

https://www.cnbc.com/2020/08/28/elon-musk-demonstrates-brain-computer-tech-neuralink-in-live-pigs.html

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/df0r1240pva5jx5apwro.jpg)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4eko1256fnz7mgw0f0pq.jpg)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/dgf3gyuwxcbzsyx52m7d.jpg)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6kog6o516lik8waz9swv.jpg)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/wkx92bjd7q4yenykel6g.jpg)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/wv14i51xw3g69y053iso.jpg)
Building A Better Data Warehouse For The Cloud At Firebolt - Episode 148
Published: 2020-09-07 22:08:03

<p>Data warehouse technology has been around for decades and has gone through several generational shifts in that time. The current trends in data warehousing are oriented around cloud native architectures that take advantage of dynamic scaling and the separation of compute and storage. Firebolt is taking that a step further with a core focus on speed and interactivity. In this episode CEO and founder Eldad Farkash explains how the Firebolt platform is architected for high throughput, their simple and transparent pricing model to encourage widespread use, and the use cases that it unlocks through interactive query speeds.</p><p><a href='https://www.dataengineeringpodcast.com/firebolt-cloud-data-warehouse-episode-148/'>Listen Now!</a></p>
When, Why, and How To Use Web Scraping In A Nutshell
Published: 2020-09-07 22:07:08

<p>The internet is a rich source of information, but a majority of it isn't accessible programmatically through APIs or databases. To address that shortcoming there are a variety of web scraping frameworks that aid in extracting structured data from web pages. In this episode Attila Tóth shares the challenges of web data extraction, the ways that you can use it, and how Scrapy and ScrapingHub can help you with your projects.</p><p><a href='https://www.pythonpodcast.com/web-scraping-essentials-episode-278/'>Listen Now!</a></p>
How to debug code in production (Heroku) that worked fine in local environment?
Tags: beginners, vscode
Published: 2020-09-07 22:03:33

As I was saying on [Twitter](https://twitter.com/petrussola/status/1303072793005821957), one of the most frustrating things for me is to fix code that works flawlessly in my local environment and, when hosted on the cloud (Heroku in my case), it stops working. 

The way I have been dealing with it so far is going back to my code, plant some `console.log`, push the code to whatever repo I have hosted on Heroku, and examine the Heroku logs `heroku logs --tail --app {{NAME_OF_YOUR_APP}}`. It is a tedious, non-scalable and time consuming nightmare.

I thought there had to be a better way to do, so I literally Googled `add debuggers code hosted heroku`. I landed in this [Stackoverflow answer](https://stackoverflow.com/a/47779485/3630417) and it was precisely what I was looking for. You can follow the steps there and you will be able to debug your code in `VSCode` planting breakpoints. To summarise my understanding:

1. You connect to the dyno with the heroku CLI: `heroku ps:exec -app {{my-app-name}}`
2. You set up the [remote debugging](https://devcenter.heroku.com/articles/exec#remote-debugging): 

2.i. Create a `Procfile` file (no extension) and add the following line: `web: node --inspect index.js`

2.ii. Deploy the code and run the following command in the command line: `heroku ps:forward 9229 -app {{my-app-name}}` (the port number is up to you). 
2.iii. Set up the debugging environment in your Text editor. In my case, VSCode, when running the debugger, you save a configuration with the following settings:

```
{
    "type": "node",
    "request": "attach",
    "name": "Heroku",
    "address": "localhost",
    "port": 9229,
    "protocol": "inspector",
    "localRoot": "${workspaceFolder}",
    "remoteRoot": "/app"
},
```

It worked for me - I was able to place breakpoints in my code and see the execution freeze to allow inspection (like in local environment). The little red dots are not visible when setting breakpoints, for some reason, but it works anyway.

Hope it works for you too! As usual, If I have told nonsense, let me know in the comments.

ps: I see that it disconnects after some time inactive. When running the debugger on VSCode again just make sure to run `heroku ps:forward 9229 -app {{my-app-name}}` again. Otherwise, an ugly looking error alert pops up saying something about not being able to establish connection
Starting the Github Actions Hackathon 
Tags: actionshackathon, github, opensource
Published: 2020-09-07 22:01:24

Writing here my first post on [dev.to](dev.to) to hold myself accountable for this awesome contest.

I have never touched any action, even though I had a period on which I was obsessed with CI/CD, but I never had the opportunity to use, let alone implement some flows/actions.

I am excited about this hackathon, and I also have some ideas for it. Now, all I need is to start implementing them.

Good Luck to everyone and Happy coding 🦄.
What are variables?
Tags: beginners, javascript, codenewbie
Published: 2020-09-07 22:00:30

It took me a while to understand what variables mean in JavaScript. An analogy that resonated with me was to think of a variable as a storage box. The name assigned to a variable would be the sticky-label on the box; and the value of the variable would be what's actually *inside* the box. So:

Variable = storage box
Name of the variable: sticky-label on the box
Value = the contents of the box

Once that was clear, I could begin thinking of it in 'technical' terms and understood that variables store values.


# Declaring Variables 

Variables are declared by using the statements `let` and `const`. You might have heard of `var` being used but it's not so common anymore. In the simplest (maybe a bit too simple, ha) terms possible:

`let` means that the value of the variable can vary, whereas `const` means that the value of the variable is fixed and can't be changed.

# Why are variables important?

I'm only a couple of weeks into learning JS, but that's long enough to realise that we can't do much in JS without variables! It's just an integral part of this programming language. Also, variables prevent us from writing repetitive code. In the English language we use pronouns (he, she, they, etc...) to avoid repeating ourselves. In the same way, we use variables to avoid repetition in our code. 

There are other reasons for why and most importantly *how* variables are used but that is beyond the scope 😏 of this brief post.
Organize your JavaScript OOP code better with this functional programming trick
Tags: javascript, webdev, vue, react
Published: 2020-09-07 20:52:12


## Pure functions

One of the main characteristics of functional programming is the concept of **pure functions**.

Pure functions:

- **always** return the same value when called with the same arguments
- **never** change variables that are outside of their scope

This is what a pure function looks like:

```javascript
function add(a, b) {
  return a + b;
}
```

## Class methods

A class method is generally the _opposite_ of a pure function.

The purpose of class methods is usually to operate in some way on a class instance (they can do other things of course).

```javascript
class Point {
  add(point) {
    this.x += point.x;
    this.y += point.y;
    return this;
  }
}
const point = new Point(2, 3);
const point2 = point.add(new Point(3, 4));
```

## How things can get messy

An often encountered problem when using methods in this way is that you are always working on the _same_ class instance. This is fine when you only have one or two objects you're using.

But the _more_ operations and objects your code needs to use, the more you need to keep track of references to instances and making sure you're not mutating objects that are also referenced by other parts of the code accidentally.

Look at this moment.js code for example:

```javascript
const startedAt = moment();
const endedAt = startedAt.add(1, "year");

console.log(startedAt); // > 2020-02-09T13:39:07+01:00
console.log(endedAt); // > 2020-02-09T13:39:07+01:00
```

They both log the same time because you unwittingly mutate the `startedAt` variable as well, since the `add` method behaves much like the `add` method I defined on the above `Point` class.

Seems like an easy problem to spot, but imagine if you have around 15 lines of operations involving multiple objects. Time to whip out the console.logs on every other line.

## A better way

With these simple examples, the answer should be clear: You should make your methods "pure".

I say "pure" because the characteristic we care most about is that they should **not mutate** any values.

Let's rewrite the `Point`'s class `add` method:

```javascript
class Point {
  add(point) {
    return new Point(this.x + point.x, this.y + point.y);
  }
}
```

Now instead of returning a reference to the same instance, you create a _whole new instance_.

You can chain methods all you want now since you don't need to worry about mutating existing variables.

```javascript
const point1 = new Point(2, 3);
const point2 = new Point(3, 4);
const point3 = point1
  .add(point2)
  .add(point1)
  .add(point2);
```

Structuring your classes this way will also make debugging and unit testing way easier, since now you can test the output directly, instead of checking for variables getting mutated properly.

Another nice benefit is that it works nicely with the reactivity systems of libraries like Vue and React. Since creating new instances will be sure to trigger their "reactiveness".
Useful Vanilla JavaScript tricks and tips
Tags: vanilla, javascript
Published: 2020-09-07 20:41:02

Putting a + in front of a number string e.g. ‘10’ turns it into a number e.g 10.

<b>Breaking a loop</b>
Use return in a foreach method to breaks for the for loop:

e.g:

[1,2,3,4,5].forEach((n) => {
	if (n === 3) {
  	console.log(n, 'returned file')
    return
  }
  console.log(n)
})

returns:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/orisokc75nag34ft5zr4.png)

<b>Using Objects as parameters</b>
Use objects as parameters in functions so that you do not have to specify all of the parameters when you call it. e.g.

htmlGenerator({parentElement, title1, content1, content1Listener, title2 = 'Bob Marley is awesome', content2, content2Listener} = {}) {
    CODE BLOCK
}

this.htmlGenerator({parentElement: nearbySiteInfo, title1: 'Site:', content1: siteProperties.name, title2: 'Site Address:', content2: siteProperties.address})

See how content1Listener and content2Listener are not defined. This does not return in an error and if they are called in the function they return undefined as expected. This very useful when you have lots of options. 

To make defaults just use the = function like the 'Bob Marley is awesome' example above.

The same principle applies to constructors in classes. An easy way to assign an object parameter to a property of the class is the following:
Object.assign(this, arguments[0]);

Where arguments is the position in the constructor arguments where the object parameter is defined.

e.g. 
constructor({
   map,
   style,
}) {
  Object.assign(this, arguments[0]);
}

Results in the following:
constructor({
   map,
   style,
}) {
  this.map = map;
  this.style = style;  
}

The benefit of this is that this it is directly related to what is defined in the object parameter

<b>Assigning a non-writable property of an object</b>
Useful if you need to attach the parameters to the window -> i.e. can be accessible by the public.
```
Object.defineProperty(ElsaApp.Constants.Keys, 'bing', {
     value: "{{ config('maps.bing.key') }}",
     writable: false
});
```

_ denotes a private variable in a class /** also adds it to the top of the file in JS in PHPStorm
MLH powered by Github
Tags: github, mlh, fellowship, opensource
Published: 2020-09-07 20:21:18

Hello to all of the students here! 

This competition from MLH powered by Github will be very useful. If you want to apply in it, it will last for 12 weeks. It will strengthen your CV very much, and it will let you work on open source projects. It will be very useful to you.

You can apply for the second wave of MLH Fellowships. Now there are two tracks(Explorer Fellowship and Open Source Fellowship) with both full-time and part-time opportunities. But I hope it will help to choose more fellows and provide them with the good scholarships.

Apply from here : https://fellowship.mlh.io/#programs

https://techdevelopers-td.blogspot.com/2020/09/mlh-powered-by-github.html

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3n0tf5gazuefe15miulb.jpg)