Bonjour à tous,
je travail sur mon premier projet C# avec Xamarin pour développer une petite application de consultation de données à travers un mobile et je bloque sur une erreur de compilation que je ne comprend pas :
Pronostics.cs :
PronoRepository.cs :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 using SQLite; using System; using System.Collections.Generic; using System.Text; namespace GenTurfEvo.Models { [Table("")] public class Pronostics { public string DateCourse { get; internal set; } public int NumReunion { get; internal set; } public string Hippodrome { get; internal set; } public int NumCourse { get; internal set; } public int MaBase { get; internal set; } public int Ch1 { get; internal set; } public int Ch2 { get; internal set; } public int Ch3 { get; internal set; } public int Ch4 { get; internal set; } public int Ch5 { get; internal set; } public int PCh1 { get; internal set; } public int PCh2 { get; internal set; } public int PCh3 { get; internal set; } public int PCh4 { get; internal set; } public int PCh5 { get; internal set; } }
Mon erreur de compilation se situe ici :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 using GenTurfEvo.Models; using SQLite; using System; using System.Collections.Generic; using System.Threading.Tasks; namespace GenTurfEvo.Repositories { internal class PronoRepository { private readonly SQLiteAsyncConnection cn; public string StatusMessage { get; set; } public PronoRepository(string dbPath) { cn = new SQLiteAsyncConnection(dbPath); } public async Task<List<Pronostics>> GetPronosticsAsync() { try { return await cn.Table<Pronostics>().ToListAsync(); } catch (Exception ex) { StatusMessage = $"Pas de données disponibles\n Erreur : {ex.Message}"; } return new List<Pronostics>(); } } }
App.xaml.cs :
MainPage.xaml.cs :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 using System.IO; using Xamarin.Forms; using Xamarin.Essentials; using GenTurfEvo.Repositories; namespace GenTurfEvo { public partial class App : Application { private readonly string dbPath = Path.Combine(FileSystem.AppDataDirectory, "GenTurfEvo.db"); public static PronoRepository PronoRepository { get; private set; }CS0053 Accessibilité incohérente*: le type de propriété 'PronoRepository' est moins accessible que la propriété 'App.PronoRepository' GenTurfEvo C:\NewTurf\GenTurfEvo\GenTurfEvo\App.xaml.cs 11 Actifpublic App() { InitializeComponent(); PronoRepository = new PronoRepository(dbPath); MainPage = new MainPage(); } protected override void OnStart() { } protected override void OnSleep() { } protected override void OnResume() { } } }
D'avance merci de votre aide, Tchicken.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 using System; using Xamarin.Forms; namespace GenTurfEvo { public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); } private void OnClick(object sender, EventArgs e) { StackLayout parent = new StackLayout { BackgroundColor = Color.Green, Margin = new Thickness(5), Padding = new Thickness(0) }; parent.Children.Add(_ = new Frame { BackgroundColor = Color.Blue, Padding = new Thickness(0), Content = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new Label { Text="GenTurfEvo", FontSize=Device.GetNamedSize(NamedSize.Title,typeof(Label)), VerticalOptions= LayoutOptions.Center } } } } ); Content = parent; } private void OnPress(object sender, EventArgs e) { var button = (Button)sender; GenTurfEvoEntrer.BackgroundColor = Color.Green; button.Text = "Gagné"; } private void OnRelease(object sender, EventArgs e) { var button = (Button)sender; button.Text = "GenTurfEvo"; GenTurfEvoEntrer.BackgroundColor = Color.Blue; } } }
Partager