Aracılığıyla paylaş


Hızlı Başlangıç: Kod oluşturma

Bu hızlı başlangıçta, GitHub Copilot'ın doğrudan Visual Studio Code'da bağlama duyarlı kod oluşturarak SQL ve nesne ilişkisel eşleme (ORM) geliştirme sürecini nasıl hızlandırdığı hakkında bilgi ediniyorsunuz. GitHub Copilot, tabloları yapılandırmanıza, şemaları geliştirmenize ve yinelenen betikleri azaltmanıza yardımcı olur. İster T-SQL kullanıyor olun ister Entity Framework, Sequelize, Prisma veya SQLAlchemy gibi ORM'lerle çalışıyor olun, GitHub Copilot uygulama mantığı oluşturmaya odaklanmanıza yardımcı olur.

Başlayın

Bir veritabanına bağlı olduğunuzdan ve MSSQL uzantısıyla etkin bir düzenleyici penceresinin açık olduğundan emin olun. Bu bağlantı, sohbet katılımcısının @mssql veritabanı ortamınızın bağlamını anlamasına olanak tanıyarak doğru ve bağlama duyarlı öneriler sağlar. Veritabanı bağlantısı olmadan, sohbet katılımcısının anlamlı yanıtlar sağlamak için şeması veya veri bağlamı olmaz.

Aşağıdaki örneklerde, AdventureWorksLT2022 giriş sayfasından indirebileceğiniz örnek veritabanı kullanılır.

En iyi sonuçları elde etmek için tablo ve şema adlarını kendi ortamınızla eşleşecek şekilde ayarlayın.

Sohbetin ön ekini içerdiğinden @mssql emin olun. Örneğin, @mssql yazdıktan sonra sorunuzu ya da isteminizi yazın. Bu, sohbet katılımcısının SQL ile ilgili yardım istediğinizi anlamasını sağlar.

GitHub Copilot ile kod oluşturma

Bağlı veritabanınızın yapısını yansıtan ve en iyi yöntemleri izleyen SQL ve ORM uyumlu kod oluşturmak için GitHub Copilot'ı kullanın. GitHub Copilot, tabloları ve ilişkileri tanımlamaktan görünümler için betik yazmaya, geçiş dosyaları oluşturmaya veya veri erişim katmanları ve API'leri iskele oluşturmaya kadar daha hızlı ve daha güvenli bir şekilde ilerlemenize yardımcı olur.

Sohbet katılımcısı aracılığıyla sorabileceğiniz yaygın kullanım örnekleri ve örnekler aşağıda verilmiştir:

SQL kodu oluşturma

GitHub Copilot, komut dosyası oluşturma, tablo oluşturma ve değiştirme işlemlerinden depolanmış prosedürler ve görünümler yazmaya kadar çeşitli geliştirme senaryoları için SQL kodu oluşturmanıza yardımcı olabilir. Bu örneklerde, tekrarlanan SQL betiğini otomatikleştirmek ve T-SQL geliştirme için en iyi yöntemleri izlemek için GitHub Copilot'ı nasıl kullanabileceğiniz gösterilmektedir.

Şemadaki tüm tabloların betiğini oluşturma

Script out all the tables in the `SalesLT` schema as `CREATE TABLE` statements in SQL.

Saklı yordamla müşteri verilerini alma

Write a SQL stored procedure in my current database. The procedure should retrieve all customers from the `SalesLT.Customer` table where the `LastName` matches a given parameter. Make sure to use T-SQL best practices.

Tüm kısıtlamaları ve dizinleri betikleyen bir tablo oluşturma

Script out the `SalesLT.Customer` table as a `CREATE TABLE` statement, including all constraints and indexes.

İki tabloyu birleştiren bir görünümün betiğini yazma

Generate a SQL script to create a view that joins the `SalesLT.Customer` and `SalesLT.SalesOrderHeader` tables, showing customer names and their total order amounts.

Yeni sütun ekleyerek tabloyu değiştirme

Write a SQL script to alter the `SalesLT.Customer` table by adding a `last_updated` column with a default timestamp.

ORM geçişleri oluşturma

GitHub Copilot, şema bağlamınıza ve seçtiğiniz çerçeveye göre ORM uyumlu geçişler ve model tanımları oluşturabilir. Sırala'dan Entity Framework, Prisma ve SQLAlchemy'ye kadar GitHub Copilot, uygulamanızın veri modeliyle uyumlu yapı iskelesi değişikliklerine yardımcı olur.

Model oluşturup sütun ekleyin

Generate a Sequelize (JavaScript) model to add an `email` column (`varchar(256)`) to the `SalesLT.Customer` table.

Entity Framework model sınıfı oluşturma

Generate an Entity Framework model class in C# to represent a `SalesLT.ProductModel` table with `id`, `name`, and `description` columns.

Entity Framework modeli oluşturma

Generate an Entity Framework model in C# based on the existing `SalesLT.Product` table.

Tablo tanımlamak için Python kodu yazma

Write SQLAlchemy code to define a `SalesLT.OrderDetails` table with `id`, `order_date`, and `customer_id` fields, ensuring compatibility with `Python`.

Parametreli sorgu yazma

Using SQLAlchemy, write a parameterized query that retrieves all customers from the `SalesLT.Customer` table where the `LastName` matches a provided parameter.

Tablo eklemek için mevcut modeli güncelleştirme

Update my existing Prisma model (schema.prisma) to define a new `SalesLT.Order` model with `id`, `customer_id`, and `order_date` fields.

Tablo için model sınıfı oluşturma

Generate a SQLAlchemy model class for the `SalesLT.Product` table, including columns and data types.

Şablon uygulama kodu oluşturma

GitHub Copilot, SQL veritabanınızla etkileşim kuran arka uç ve ön uç bileşenlerinin geliştirilmesine de yardımcı olabilir. Bu örneklerde Azure İşlevleri, Node.js, Django ve Next.jsgibi popüler yığınları kullanarak şemadan çalışan uygulama koduna nasıl geçebileceğiniz gösterilmektedir.

Sunucusuz arka uç SQL bağlamaları ve Blazor

Aşağıdaki örnekte, uçtan uca bir çözümün iskelesini oluşturmak için GitHub Copilot Chat ile kullanabileceğiniz tüm istemler gösterilmektedir. Bu istemler, Copilot'un hem arka uç hem de ön uç katmanlarında doğru, yapılandırılmış kod oluşturmasına yardımcı olacak ayrıntılı yönergeler ve bağlam içerir.

Generate a full-stack app using Azure SQL bindings for Functions and Blazor WebAssembly. Follow these steps:

1. Backend: Azure Functions (C#) with SQL Bindings

   - Configure SQL Bindings to automatically read and write data from the `SalesLT.Customer` table.
   - Implement HTTP-triggered functions with the following endpoints:
     - `GET /api/customers` – Fetch all customers.
     - `GET /api/customers/{id}` – Get a specific customer by ID.
     - `POST /api/customers` – Create a new customer.
     - `PUT /api/customers/{id}` – Update an existing customer.
     - `DELETE /api/customers/{id}` – Delete a customer.
   - Use `Dependency Injection` for database connections and logging.
   - Include an `appsettings.json` file to store database connection strings and environment variables.
   - Use `Azure Functions Core Tools` to run and test the functions locally.

1. Frontend: Blazor WebAssembly (Optional)

   - Create a Blazor WebAssembly frontend that consumes the API.
   - Display a table with customer data and a form to add new customers.
   - Use `HttpClient` to call the Azure Functions endpoints.
   - Implement two-way data binding to handle form inputs dynamically.
   - Use Bootstrap or Blazor components for styling and layout.

Ensure the project includes setup instructions for running both the Azure Functions backend and Blazor WebAssembly frontend locally, with proper `.env` or `local.settings.json` configurations for database connections.

Node.js ve Next.js ile tam yığın

Aşağıdaki örnek, API yolları ve veritabanı tümleştirmesi dahil olmak üzere tam arka uç kurulumu oluşturmak için GitHub Copilot Chat'te sağlayabileceğiniz ayrıntılı bir istemdir.

Generate a REST API using Node.js with Express that connects to my local SQL Database. Use the Tedious package for SQL Server connections and Prisma as the ORM. Follow these steps:

1. Backend: Node.js + Express

   - Establish a database connection using Prisma with Tedious as the SQL Server driver.
   - Implement API routes for `SalesLT.Customer` with the following endpoints:
     - `GET /customers` – Fetch all customers.
     - `GET /customers/:id` – Get a specific customer by ID.
     - `POST /customers` – Create a new customer.
     - `PUT /customers/:id` – Update an existing customer.
     - `DELETE /customers/:id` – Delete a customer.
   - Configure `Prisma` to map the `SalesLT.Customer` table and generate database migrations using `prisma migrate dev`.
   - Use `dotenv` for environment variables (database credentials, ports, etc.).
   - Add `Jest` for testing the API endpoints.

1. Frontend: Next.js + TypeScript (Optional)

   - Create a Next.js frontend that consumes the API.
   - Display a table with customer data and a form to add new customers.
   - Use React hooks (`useState`, `useEffect`) to manage state and fetch data dynamically.
   - Style the UI using Tailwind CSS.
   - Implement server-side data fetching (`getServerSideProps`) in Next.js for improved performance.

Ensure the project includes setup instructions for running both the backend and frontend independently, with proper `.env` configurations for the database connection.

Arka uç: Django + Django REST çerçevesi

Aşağıdaki örnek, API yolları ve veritabanı tümleştirmesi dahil olmak üzere tam arka uç kurulumu oluşturmak için GitHub Copilot Chat'te sağlayabileceğiniz ayrıntılı bir istemdir.

Scaffold a Django backend with Django REST Framework for the `SalesLT.Customer` table. Follow these steps:

- Implement API routes using Django's `ModelViewSet` with the following endpoints:
  - `GET /customers` – Fetch all customers.
  - `GET /customers/{id}` – Get a specific customer by ID.
  - `POST /customers` – Create a new customer.
  - `PUT /customers/{id}` – Update an existing customer.
  - `DELETE /customers/{id}` – Delete a customer.

- Add instructions for generating database migrations with `python manage.py makemigrations` and `migrate`.

Deneyiminizi paylaşma

MSSQL uzantısı için GitHub Copilot'ı geliştirmemize ve geliştirmemize yardımcı olmak için aşağıdaki GitHub sorun şablonunu kullanarak geri bildiriminizi gönderin: GitHub Copilot Geri Bildirimi

Geri bildirim gönderirken şunları dahil etmeyi göz önünde bulundurun:

  • Test edilen senaryolar : Şema oluşturma, sorgu oluşturma, güvenlik, yerelleştirme gibi hangi alanlara odaklandığınız konusunda bize bilgi verin.

  • Başarılı Olanlar - Sorunsuz, yararlı veya beklentilerinizi aşan deneyimlerinizi açıklayın.

  • Sorunlar veya hatalar : Tüm sorunları, tutarsızlıkları veya kafa karıştırıcı davranışları içerir. Ekran görüntüleri veya ekran kayıtları özellikle yararlıdır.

  • İyileştirme önerileri : Kullanılabilirliği artırma, kapsamı genişletme veya GitHub Copilot'un yanıtlarını geliştirmeyle ilgili fikirleri paylaşın.