Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Microsoft.WindowsAzure.Storage;
- using Microsoft.WindowsAzure.Storage.Table;
- using System.Threading.Tasks;
- //CLASA
- namespace Seba
- {
- public class Student: TableEntity
- {
- public Student(string f, string r ){
- this.PartitionKey=f;
- this.RowKey=r;
- }
- public Student(){}
- public string Name { get; set; }
- public string Email { get; set; }
- }
- }
- ///main
- using System;
- using Microsoft.WindowsAzure.Storage;
- using Microsoft.WindowsAzure.Storage.Table;
- using System.Threading.Tasks;
- namespace Seba
- {
- class Program
- {
- static void Main(string[] args)
- {
- Task.Run(async () => {
- await conectare_tabel();
- }).GetAwaiter().GetResult();
- // try
- // {
- // // conectare_tabel().Wait();
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine($"There was an exception: {ex.ToString()}");
- // }
- }
- async static Task instantiere_fields(CloudTable peopleTable)
- {
- Student st = new Student("AC", "1921215355555");
- st.Name = "Sebastian LEONTI";
- st.Email = "sebastanopol@gmail.com";
- TableOperation insertOperation = TableOperation.Insert(st);
- await peopleTable.ExecuteAsync(insertOperation);
- }
- async static Task conectare_tabel()
- {
- CloudStorageAccount storageAccount = new CloudStorageAccount(
- new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(
- "datcdemovineri", "yDSrMBCO7cHeRHJMkTbG1MZ3i7HKKWOMdcoHhe4N3iFn/VCZYgnN1AQ5Ga/LxidOzgv0llbT4ZXpUU2UO+12wQ=="), true);
- // Create the table client.
- CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
- // Get a reference to a table named "peopleTable"
- CloudTable peopleTable = tableClient.GetTableReference("StudentiLS");
- await CreatePeopleTableAsync(peopleTable);
- await cautare(peopleTable);
- }
- async static Task CreatePeopleTableAsync(CloudTable peopleTable)
- {
- // Create the CloudTable if it does not exist
- await peopleTable.CreateIfNotExistsAsync();
- // await instantiere_fields(peopleTable);
- }
- async static Task cautare(CloudTable peopleTable)
- {
- // Construct the query operation for all customer entities where PartitionKey="Smith".
- TableQuery<Student> query = new TableQuery<Student>(); //.Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "AC"));
- // Print the fields for each customer.
- TableContinuationToken token = null;
- do
- {
- TableQuerySegment<Student> resultSegment = await peopleTable.ExecuteQuerySegmentedAsync(query, token);
- token = resultSegment.ContinuationToken;
- foreach (Student entity in resultSegment.Results)
- {
- Console.WriteLine("{0}, {1}\t{2}", entity.PartitionKey, entity.RowKey,
- entity.Email);
- }
- } while (token != null);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement