Click here to Skip to main content
15,564,475 members
Home / Discussions / C#
   

C#

 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Exoskeletor9-Mar-20 5:05
Exoskeletor9-Mar-20 5:05 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Eddy Vluggen9-Mar-20 5:11
professionalEddy Vluggen9-Mar-20 5:11 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Exoskeletor9-Mar-20 5:28
Exoskeletor9-Mar-20 5:28 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Eddy Vluggen9-Mar-20 5:44
professionalEddy Vluggen9-Mar-20 5:44 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Exoskeletor9-Mar-20 5:47
Exoskeletor9-Mar-20 5:47 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Eddy Vluggen9-Mar-20 5:51
professionalEddy Vluggen9-Mar-20 5:51 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Exoskeletor9-Mar-20 6:00
Exoskeletor9-Mar-20 6:00 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Exoskeletor9-Mar-20 6:28
Exoskeletor9-Mar-20 6:28 
also i tried in this code

public static void AddTemplate(int category, List<int> images)
        {
            var templateDB = new TemplateDB();
            var imageByteList = new List<byte[]>();

            foreach (int image in images)
            {
                //imageByteList.Add(templateDB.DrawableToByteArray(image));
            }
            var tmpl = new Template()
            {
                Category = category,
            };
            var img1 = new TemplateImage()
            {
                Category = category,
                Image = images[0],
                //ImagesHash = DatabaseHelper.GetMD5Hash(imageByteList[0]),
            };
            var img2 = new TemplateImage()
            {
                Category = category,
                Image = images[1],
                //ImagesHash = DatabaseHelper.GetMD5Hash(imageByteList[1]),
            };
            var img3 = new TemplateImage()
            {
                Category = category,
                Image = images[2],
                //ImagesHash = DatabaseHelper.GetMD5Hash(imageByteList[2]),
            };
            var img4 = new TemplateImage()
            {
                Category = category,
                Image = images[3],
                //ImagesHash = DatabaseHelper.GetMD5Hash(imageByteList[3]),
            };
            var img5 = new TemplateImage()
            {
                Category = category,
                Image = images[4],
                //ImagesHash = DatabaseHelper.GetMD5Hash(imageByteList[4]),
            };
            tmpl.TemplateImages = new List<TemplateImage>() { img1, img2, img3, img4, img5 };
            //tmpl.ImagesHash = DatabaseHelper.GetMD5Hash(ConcatByteList(imageByteList));
            var result = DatabaseHelper.db().Query<TemplateImage>("Select * from Templates where ImagesHash=?", tmpl.ImagesHash);
            if (result.Count == 0)
            {
            DatabaseHelper.db().InsertAll(tmpl.TemplateImages);
            DatabaseHelper.db().Insert(tmpl);
            DatabaseHelper.db().UpdateWithChildren(tmpl);
            }


to replace insert with insertorupdate and my template database was empty. id was always 0 in every attemp to insert something to db, do you know why? here is the database structure

[Table("Templates")]
    public class Template
    {
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }
        public int Category { get; set; }
        //[TextBlob("imagesBlobbed")]
        [OneToMany, Unique]
        public List<TemplateImage> TemplateImages { get; set; }
        public string ImagesHash { get; set; }
        //public string imagesBlobbed { get; set; }
    }
    [Table("TemplateImages")]
    public class TemplateImage
    {
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }
        public int Category { get; set; }
        public string ImagesHash { get; set; }
        public int Image { get; set; }
        [ForeignKey(typeof(Template))]
        public int TemplateId { get; set; }
    }

GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Eddy Vluggen9-Mar-20 10:00
professionalEddy Vluggen9-Mar-20 10:00 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Exoskeletor9-Mar-20 10:03
Exoskeletor9-Mar-20 10:03 
QuestionRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Eddy Vluggen9-Mar-20 10:13
professionalEddy Vluggen9-Mar-20 10:13 
AnswerRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Exoskeletor9-Mar-20 10:16
Exoskeletor9-Mar-20 10:16 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Eddy Vluggen9-Mar-20 10:53
professionalEddy Vluggen9-Mar-20 10:53 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Eddy Vluggen9-Mar-20 9:58
professionalEddy Vluggen9-Mar-20 9:58 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Eddy Vluggen9-Mar-20 5:14
professionalEddy Vluggen9-Mar-20 5:14 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Exoskeletor9-Mar-20 10:09
Exoskeletor9-Mar-20 10:09 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Eddy Vluggen9-Mar-20 10:15
professionalEddy Vluggen9-Mar-20 10:15 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Exoskeletor9-Mar-20 10:31
Exoskeletor9-Mar-20 10:31 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Eddy Vluggen9-Mar-20 10:49
professionalEddy Vluggen9-Mar-20 10:49 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Exoskeletor9-Mar-20 15:18
Exoskeletor9-Mar-20 15:18 
PraiseRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Eddy Vluggen10-Mar-20 2:44
professionalEddy Vluggen10-Mar-20 2:44 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Eddy Vluggen9-Mar-20 3:23
professionalEddy Vluggen9-Mar-20 3:23 
GeneralRe: Converting List<int> to List<object> for One to Many relation with sqlite-net-extensions Pin
Exoskeletor9-Mar-20 1:26
Exoskeletor9-Mar-20 1:26 
QuestionHow do I make table data red in <td>? Pin
Member 114033044-Mar-20 9:33
Member 114033044-Mar-20 9:33 
AnswerRe: How do I make table data red in <td>? Pin
Richard Deeming4-Mar-20 9:50
mveRichard Deeming4-Mar-20 9:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.