当前位置: 首页>>代码示例>>C#>>正文


C# RowSet.AddRow方法代码示例

本文整理汇总了C#中RowSet.AddRow方法的典型用法代码示例。如果您正苦于以下问题:C# RowSet.AddRow方法的具体用法?C# RowSet.AddRow怎么用?C# RowSet.AddRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RowSet的用法示例。


在下文中一共展示了RowSet.AddRow方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateStringsRowset

 /// <summary>
 /// Creates a rowset.
 /// The columns are named: col_0, ..., col_n
 /// The rows values are: row_0_col_0, ..., row_m_col_n
 /// </summary>
 public RowSet CreateStringsRowset(int columnLength, int rowLength, string valueModifier = null)
 {
     var columns = new List<CqlColumn>();
     var columnIndexes = new Dictionary<string, int>();
     for (var i = 0; i < columnLength; i++)
     {
         var c = new CqlColumn()
         {
             Index = i,
             Name = "col_" + i,
             TypeCode = ColumnTypeCode.Text,
             Type = typeof(string)
         };
         columns.Add(c);
         columnIndexes.Add(c.Name, c.Index);
     }
     var rs = new RowSet();
     for (var j = 0; j < rowLength; j++)
     {
         var rowValues = new List<byte[]>();
         foreach (var c in columns)
         {
             var value = valueModifier + "row_" + j + "_col_" + c.Index;
             rowValues.Add(Encoding.UTF8.GetBytes(value));
         }
         rs.AddRow(new Row(1, rowValues.ToArray(), columns.ToArray(), columnIndexes));
     }
     return rs;
 }
开发者ID:rasmus-s,项目名称:csharp-driver,代码行数:34,代码来源:RowSetUnitTests.cs

示例2: CreateSampleRowSet

 /// <summary>
 /// Creates a RowSet with few rows with int, text columns (null values in the last row)
 /// </summary>
 private static RowSet CreateSampleRowSet()
 {
     var columns = new List<CqlColumn>
     {
         new CqlColumn()
         {
             Index = 0,
             Name = "text_sample",
             TypeCode = ColumnTypeCode.Text,
             Type = typeof (string)
         },
         new CqlColumn()
         {
             Index = 1,
             Name = "int_sample",
             TypeCode = ColumnTypeCode.Int,
             Type = typeof(int)
         }
     };
     var columnIndexes = columns.ToDictionary(c => c.Name, c => c.Index);
     var rs = new RowSet();
     var rowValues = new object[]
     {
         "text value",
         100
     };
     rs.AddRow(new Row(rowValues, columns.ToArray(), columnIndexes));
     rs.AddRow(new Row(new object[] { null, null}, columns.ToArray(), columnIndexes));
     return rs;
 }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:33,代码来源:RowSetUnitTests.cs

示例3: CreateStringsRowset

 /// <summary>
 /// Creates a rowset.
 /// The columns are named: col_0, ..., col_n
 /// The rows values are: row_0_col_0, ..., row_m_col_n
 /// </summary>
 private static RowSet CreateStringsRowset(int columnLength, int rowLength, string valueModifier = null)
 {
     var columns = new List<CqlColumn>();
     var columnIndexes = new Dictionary<string, int>();
     for (var i = 0; i < columnLength; i++)
     {
         var c = new CqlColumn()
         {
             Index = i,
             Name = "col_" + i,
             TypeCode = ColumnTypeCode.Text,
             Type = typeof(string)
         };
         columns.Add(c);
         columnIndexes.Add(c.Name, c.Index);
     }
     var rs = new RowSet();
     for (var j = 0; j < rowLength; j++)
     {
         rs.AddRow(new Row(columns.Select(c => valueModifier + "row_" + j + "_col_" + c.Index).Cast<object>().ToArray(), columns.ToArray(), columnIndexes));
     }
     return rs;
 }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:28,代码来源:RowSetUnitTests.cs

示例4: Execute

        /// Execute action
        public override object Execute()
        {
            downloadPackagesInfo();

            RowSet rs=new RowSet();
            Context.Initialize(rs);

            List<Package> toUpdate = new List<Package>();
            var filter = new StringFilter(Syntax, Context.TransformStr(Filter, Transform));
            //VerboseMessage("Filter: {0} {1}", Syntax, Dump.ToDump( Context.TransformStr(Filter, Transform)));
            foreach (var c in Items)
            {
                var rv=c.CheckVersion();
                Version currentVersion = null;
                string str = (rv==null?null:(ReturnValue.Unwrap(rv)??string.Empty).ToString());
                if (!string.IsNullOrEmpty(str))
                    currentVersion = new Version(str);

                var pinfo = GetPackage(c.Name);
                Version newVersion =(pinfo != null) ?pinfo.Version:null;

                rs.AddRow(new Vars(){
                    {"Package",c.FriendlyName},
                    {"Installed",(currentVersion==null)?"not installed":currentVersion.ToString()},
                    {"Available",(newVersion == null) ? "n/a" : newVersion.ToString()}}
                );

                bool update = false;
                if (currentVersion != null && ((newVersion > currentVersion) || ForceUpdate) && filter.IsMatch(c.Name))
                {
                    toUpdate.Add(c);
                    update = true;
                }
                VerboseMessage("{0}: {1}=>{2}. Update={3}",c.Name,currentVersion,newVersion,update);
            }

            Context.Out.WriteLine(string.Empty);
            Context.Out.WriteLine(rs.ToTextTable(TableFormatOptions.Header));

            if (toUpdate.Count==0)
            {
                Context.Out.WriteLine("All packages are up to date!");
                return null;
            }

            try
            {
                VerboseMessage("--- Downloading components... --- ");
                foreach (var c in toUpdate)
                    c.Download(this);
                VerboseMessage("--- Download completed. --- ");
                VerboseMessage(string.Empty);

                VerboseMessage("--- Starting update... ---");
                Context.Execute(BeforeUpdate);
                try
                {
                    foreach (var c in toUpdate)
                        c.DoUpdate(this);
                }
                finally
                {
                    Context.Execute(AfterUpdate);
                }
                VerboseMessage("--- Update completed. ---");
                VerboseMessage(string.Empty);
                return null;
            }
            finally
            {
                if (Cleanup)
                {
                    VerboseMessage("--- Cleaning up... ---");
                    foreach (var c in toUpdate)
                    {
                        try
                        {
                            c.Cleanup(this);
                        }
                        catch
                        {
                            Context.WriteLine(OutputType.Error, string.Format("Cleanup failed for {0}...", c.Name));
                        }
                    }
                    VerboseMessage("--- Cleaning completed. ---");
                    VerboseMessage(string.Empty);

                }
            }
        }
开发者ID:xsharper,项目名称:xsharper,代码行数:91,代码来源:Updater.cs

示例5: Fetch_Maps_NullableDateTime_Test

 public void Fetch_Maps_NullableDateTime_Test()
 {
     var rs = new RowSet
     {
         Columns = new[]
         {
             new CqlColumn {Name = "id", TypeCode = ColumnTypeCode.Uuid, Type = typeof (Guid), Index = 0},
             new CqlColumn {Name = "title", TypeCode = ColumnTypeCode.Text, Type = typeof (string), Index = 1},
             new CqlColumn {Name = "releasedate", TypeCode = ColumnTypeCode.Timestamp, Type = typeof (DateTimeOffset), Index = 2}
         }
     };
     var values = new object[] { Guid.NewGuid(), "Come Away with Me", DateTimeOffset.Parse("2002-01-01 +0")}
         .Select(v => TypeCodec.Encode(2, v));
     var row = new Row(2, values.ToArray(), rs.Columns, rs.Columns.ToDictionary(c => c.Name, c => c.Index));
     rs.AddRow(row);
     var sessionMock = new Mock<ISession>(MockBehavior.Strict);
     sessionMock
         .Setup(s => s.ExecuteAsync(It.IsAny<BoundStatement>()))
         .Returns(TestHelper.DelayedTask(rs, 100))
         .Verifiable();
     sessionMock
         .Setup(s => s.PrepareAsync(It.IsAny<string>()))
         .Returns(TaskHelper.ToTask(GetPrepared()))
         .Verifiable();
     var mapper = GetMappingClient(sessionMock);
     var song = mapper.Fetch<Song2>(new Cql("SELECT * FROM songs")).First();
     Assert.AreEqual("Come Away with Me", song.Title);
     Assert.AreEqual(DateTimeOffset.Parse("2002-01-01 +0").DateTime, song.ReleaseDate);
 }
开发者ID:Virus-X,项目名称:csharp-driver,代码行数:29,代码来源:FetchTests.cs

示例6: CreateSampleRowSet

 /// <summary>
 /// Creates a RowSet with few rows with int, text columns (null values in the last row)
 /// </summary>
 private static RowSet CreateSampleRowSet()
 {
     var columns = new List<CqlColumn>
     {
         new CqlColumn()
         {
             Index = 0,
             Name = "text_sample",
             TypeCode = ColumnTypeCode.Text,
             Type = typeof (string)
         },
         new CqlColumn()
         {
             Index = 1,
             Name = "int_sample",
             TypeCode = ColumnTypeCode.Int,
             Type = typeof(int)
         }
     };
     var columnIndexes = columns.ToDictionary(c => c.Name, c => c.Index);
     var rs = new RowSet();
     var rowValues = new[]
     {
         Encoding.UTF8.GetBytes("text value"),
         TypeCodec.EncodeInt(2, null, 100)
     };
     rs.AddRow(new Row(2, rowValues, columns.ToArray(), columnIndexes));
     rowValues = new byte[][]
     {
         null,
         null
     };
     rs.AddRow(new Row(2, rowValues, columns.ToArray(), columnIndexes));
     return rs;
 }
开发者ID:Virus-X,项目名称:csharp-driver,代码行数:38,代码来源:RowSetUnitTests.cs


注:本文中的RowSet.AddRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。