question

Grime avatar image
0 Votes"
Grime asked LeonLu-MSFT commented

Combined Variable Question

I don't yet know enough about Xamarin terminology to probably make sense, but I was doing OK following the James Montemagno YouTube video, "https://www.youtube.com/watch?v=XFP8Np-uRWc" until I had to create a "collective variable" (?)!

What might I be doing wrong?https://docs.microsoft.com/answers/storage/attachments/88628-clipboard01.png

dotnet-xamarin
clipboard01.png (1.2 MiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LeonLu-MSFT avatar image
0 Votes"
LeonLu-MSFT answered LeonLu-MSFT commented

Hello,​

Welcome to our Microsoft Q&A platform!

First of all, did you create model class like following code?

public class Operator
    {
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }
        public string OpName { get; set; }
        public string OpPhone { get; set; }
        public string OpEmail { get; set; }
    }


When you create new object, you should write following code.

var operators = new Operator()
            {
                OpName = "Opname1",
                OpPhone = "O12345566",
                OpEmail = "test@test.com"

            };


Best Regards,

Leon Lu



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@LeonLu-MSFT Yes to class Operators
using System;
using System.Collections.Generic;
using System.Text;
using SQLite;

 namespace HandsFreeNotes.Model
 {
     class Operators // Because Operator is a reserved word
     {
         [PrimaryKey, AutoIncrement]
         public int ID { get; set; }
         [Indexed]
         public string OpName { get; set; }
         public string OpPhone { get; set; }
         public string OpEmail { get; set; }
     }
 }
0 Votes 0 ·

When you create new Operators, which error did you met? Create new Operators like my above code, is that not work?

0 Votes 0 ·

As to "When you create new object, you should write following code." How is that following what Montemagno was doing? OK, it reduces my error count...

0 Votes 0 ·

So I am left with one error:
public static async Task<IEnumerable<Operators>>GetOperators()

Where do i declare GetOperators.

0 Votes 0 ·

When you getOperators(); change the from public static async Task<IEnumerable<Operators>>GetOperators() to public static async Task<List<Operators>>GetOperators() is better, because var result = await query.ToListAsync(); this result type is List.

0 Votes 0 ·
Show more comments