Je suis coincé dans une jointure et je ne peux pas comprendre où est le problème, j’ai ces tables
public class Themes { [PrimaryKey, AutoIncrement] public int Id { get; set; } public Ssortingng ThemeName { get; set; } public Ssortingng ThemeDesc { get; set; } public int ThemeImg { get; set; } public Ssortingng ThemeCategory { get; set; } public Ssortingng ThemeSubcategory { get; set; } } public class MusicItems { [PrimaryKey, AutoIncrement] public int Id { get; set; } public Ssortingng Name { get; set; } public Ssortingng Tension { get; set; } public Ssortingng Category { get; set; } public Ssortingng Subcategory { get; set; } public int ResId { get; set; } public int LoopStart { get; set; } } public class Playlist { public Ssortingng Name { get; set; } public int ResId { get; set; } public int LoopStart { get; set; } } public class MusicInThemes { [PrimaryKey, AutoIncrement] public int Id { get; set; } public int ResId { get; set; } public int ThemeId { get; set; } }
Et je souhaite rejoindre MusicItems avec MusicInThemes afin d’obtenir tous les détails des fichiers musicaux appartenant à un thème. Jusqu’à présent, j’ai essayé ces applications qui bloquent mon application:
var query = from MusicItem in database.Table() join Theme in database.Table() on MusicItem.ResId equals Theme.ResId where Theme.ThemeId == ThemeID select new Playlist{Name = MusicItem.Name, ResId = MusicItem.ResId ,LoopStart = 0}; return query.ToList(); // and return database.Table() .Join(database.Table().Where(t => t.ThemeId == ThemeID) ,m => m.ResId ,t => t.ResId ,(m,t) => new Playlist{Name = m.Name, ResId = m.ResId ,LoopStart = m.LoopStart}) .ToList();
Et c’est le code où j’obtiens la liste de lecture: (j’ai 2 boutons. Le btnTheme1 affiche des informations sur le thème et enregistre des variables de thème puis le bouton loadTheme tente d’extraire les morceaux du thème sélectionné)
ThemeImage = view.FindViewById (Resource.Id.imgThemeImage); ThemeDesc = view.FindViewById (Resource.Id.txtDesc); Button btnTheme1 = view.FindViewById
S’il vous plaît des conseils
Debug Log: ... [Mono] Assembly Ref addref Music[0xb95c8210] -> Newtonsoft.Json[0xb95ca100]: 2 [Mono] The request to load the retargetable assembly mscorlib v2.0.5.0 was remapped to mscorlib v2.0.5.0 [Mono] Assembly Ref addref Newtonsoft.Json[0xb95ca100] -> mscorlib[0xb9406208]: 7 [Mono] Assembly Ref addref System.Core[0xb960c248] -> System[0xb972dd18]: 4 [MediaPlayer-JNI] MediaPlayer finalized without being released [MediaPlayer-JNI] MediaPlayer finalized without being released [MediaPlayer-JNI] MediaPlayer finalized without being released [MediaPlayer-JNI] MediaPlayer finalized without being released [Mono] GC_OLD_BRIDGE num-objects 44 num_hash_ensortinges 47 sccs size 47 init 0.00ms df1 0.19ms sort 0.30ms dfs2 1.39ms setup-cb 0.01ms free-data 0.12ms links 3/3/3/1 dfs passes 94/50 [Mono] GC_MINOR: (Nursery full) pause 19.83ms, total 19.96ms, bridge 11.96ms promoted 784K major 1072K los 8K [Mono] GC_OLD_BRIDGE num-objects 44 num_hash_ensortinges 47 sccs size 47 init 0.00ms df1 0.19ms sort 0.30ms dfs2 1.39ms setup-cb 0.01ms free-data 0.12ms links 0/0/0/0 dfs passes 0/0 [Mono] GC_MINOR: (Nursery full) pause 11.56ms, total 11.67ms, bridge 0.17ms promoted 368K major 1440K los 8K [] * Assertion at /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/mono/mono/metadata/sgen-stw.c:68, condition `info->stack_start >= info->stack_start_limit && info->stack_start stack_end' not met [mono-rt] Stacktrace: [mono-rt] [mono-rt] at [mono-rt] at (wrapper managed-to-native) object.__icall_wrapper_mono_array_new_specific (intptr,int) [mono-rt] at System.Collections.Concurrent.SplitOrderedList`2<string, System.Collections.Generic.KeyValuePair`2>..ctor (System.Collections.Generic.IEqualityComparer`1) [mono-rt] at System.Collections.Concurrent.ConcurrentDictionary`2..ctor (System.Collections.Generic.IEqualityComparer`1) [mono-rt] at System.Collections.Concurrent.ConcurrentDictionary`2..ctor () [mono-rt] at SQLite.TableMapping..ctor (System.Type,SQLite.CreateFlags) [0x0019d] in c:\Users\Exoskeletor\Documents\Projects\Music\Music\Helpers\SQLite.cs:1755 [mono-rt] at SQLite.SQLiteConnection.GetMapping (System.Type,SQLite.CreateFlags) [0x00036] in c:\Users\Exoskeletor\Documents\Projects\Music\Music\Helpers\SQLite.cs:304 [mono-rt] at SQLite.TableQuery`1..ctor (SQLite.SQLiteConnection) [0x00010] in c:\Users\Exoskeletor\Documents\Projects\Music\Music\Helpers\SQLite.cs:2473 [mono-rt] at SQLite.SQLiteConnection.Table () [0x00001] in c:\Users\Exoskeletor\Documents\Projects\Music\Music\Helpers\SQLite.cs:768 [mono-rt] at Music.DataManager.DatabaseUpdates.GetPlaylist (int,ssortingng) [0x00027] in c:\Users\Exoskeletor\Documents\Projects\Music\Music\Helpers\DataManagerHelper.cs:288 [mono-rt] at Music.Music_SelectTheme/c__DisplayClass2.b__1 (object,System.EventArgs) [0x00001] in c:\Users\Exoskeletor\Documents\Projects\Music\Music\Music_SelectTheme.cs:77 [mono-rt] at Android.Views.View/IOnClickListenerImplementor.OnClick (Android.Views.View) [0x0000d] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.Views.View.cs:1615 [mono-rt] at Android.Views.View/IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.Views.View.cs:1582 [mono-rt] at (wrapper dynamic-method) object.a2a00f7c-dc24-4757-ba0d-9fa6ea56b30a (intptr,intptr,intptr) [mono-rt] at (wrapper native-to-managed) object.a2a00f7c-dc24-4757-ba0d-9fa6ea56b30a (intptr,intptr,intptr) [mono-rt] [mono-rt] ================================================================= [mono-rt] Got a SIGSEGV while executing native code. This usually indicates [mono-rt] a fatal error in the mono runtime or one of the native libraries [mono-rt] used by your application. [mono-rt] ================================================================= [mono-rt] [libc] Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 1385 (Music.Music)
Pour l’instant, SQLite
ne prend pas en charge la connexion via Linq
à ma connaissance. J’ai dû utiliser la syntaxe de requête comme ceci:
var q = database.Query( "select MI.Name, MI.ResId, MI.Tension from MusicItems MI" + " inner join MusicInThemes MT" + " on MI.ResId = MT.ResId where MT.ThemeId = ?", ThemeID).ToList(); return q.Select(x => new Playlist { Name = x.Name, ResId = x.ResId, LoopStart = x.LoopStart });
utiliser le symbole ‘@’ devant la requête le rendra plus simple et plus lisible.
var musicFiles = database.Query(@"select MI.Name, MI.ResId, MI.Tension from MusicItems MI inner join MusicInThemes MT on MI.ResId = MT.ResId where MT.ThemeId = ?", ThemeID).ToList();