Beispiel #1
0
        public void InsertContent(string command, string dbName)
        {
            var tableName = DbApiHelper.GetName(command);

            DbApiHelper.OpenDbForAction(_сontentFolder, dbName, database =>
            {
                return(DbApiHelper.OpenTableForAction(database, tableName, table =>
                {
                    var metaInfoNodes =
                        table.Descendants(_columnInfoTagName)
                        .First()
                        .Elements()
                        .Select(x => new { x.Name, x.Value }).ToArray();

                    var insertingLines = DbApiHelper.GetValues(command);
                    foreach (var line in insertingLines)
                    {
                        var newRecord = new XElement(AnyRecordName,
                                                     line.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries)
                                                     .Select((value, i) => new XAttribute(metaInfoNodes[i].Name, value)));

                        table.Descendants(_columnContentTagName).First().Add(newRecord);
                    }

                    return null;
                }));
            });
        }