0

I got one big question.

Below is the code I used to store string[] arrays in database, but I cannot Get them from database.

my Model:

public class TokenTransaction
{
    [Key]
    public int Id { get; set; }
    public string Token { get; set; }
    public string[] baskets { get; set; }
}

and MydbContext.cs:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<TokenTransaction>()
        .Property(a => a.baskets).HasConversion(
            t => string.Join(';', t),
            t => t.Split(';', StringSplitOptions.RemoveEmptyEntries));
}

The code I used to get a database record for that model is:

 public TokenTransaction GetTokenTransaction(string InvoiceID)
{
   return  _Context.TokenTransactions
        .FirstOrDefault(t => t.CodePeygiry == InvoiceID);
}

Error in:

SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.) -

I don't know why this error appears. Could you please help me to retrieve data from the database?

azita
  • 11
  • 3
  • The error indicates you could not open the connection to Sql Server,you could found similar issue like:https://stackoverflow.com/questions/17615260/the-certificate-chain-was-issued-by-an-authority-that-is-not-trusted-when-conn – Ruikai Feng Dec 19 '22 at 09:20
  • Thank you Ruikai Feng, My error was solved when I used TrustServerCertificate=True in the connection string – azita Dec 19 '22 at 10:05
  • See the duplicate: other data type, same problem. – Gert Arnold Dec 19 '22 at 10:12

0 Answers0