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


C# DataColumnCollection.Contains方法代码示例

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


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

示例1: CourseRubricObject

 public CourseRubricObject(DataColumnCollection columns, DataRow row)
 {
     this.id = columns.Contains("id") ? Convert.ToInt32(row["id"]) : -1;
     this.courseId = columns.Contains("course_id") ? Convert.ToInt32(row["course_id"]) : -1;
     this.courseName = columns.Contains("course_name") ? Convert.ToString(row["course_name"]) : "-";
     this.rubricName = columns.Contains("rubric_name") ? Convert.ToString(row["rubric_name"]) : "-";
 }
开发者ID:idurlen92,项目名称:E_Grader,代码行数:7,代码来源:CourseRubricObject.cs

示例2: ExistColumn

 /// <summary>
 /// Checks if the columnList names are included in columns names.
 /// </summary>
 /// <param name="columnList">column list names</param>
 /// <param name="columns">DataColumn collection</param>
 /// <returns>True if all are included, otherwise false</returns>
 public static bool ExistColumn(string[] columnList, DataColumnCollection columns)
 {
     foreach (string column in columnList)
     {
         if (!columns.Contains(column))
         {
             return false;
         }
     }
     return true;
 }
开发者ID:sgon1853,项目名称:UPM_MDD_Thesis,代码行数:17,代码来源:UtilFunctions.cs

示例3: ToString

        //public static Int32 ToInt32(this DataRow dr,DataColumnCollection dc, string field)
        //{
        //    if (dc.Contains(field))
        //    {
        //        return ToInt32(dr[field].ToString());
        //    }
        //    else
        //    {
        //        return 0;
        //    }
        //}

        public static string ToString(this DataRow dr, DataColumnCollection dc, string field)
        {
            if (dc.Contains(field))
            {
                return dr[field].ToString();
            }
            else
            {
                return "";
            }
        }
开发者ID:sclynton,项目名称:CrazyBull,代码行数:23,代码来源:StringExtention.cs

示例4: ClassInSchoolObject

 public ClassInSchoolObject(DataColumnCollection columns, DataRow row)
 {
     this.id = columns.Contains("id") ? Convert.ToInt32(row["id"]) : -1;
     this.classId = (columns.Contains("class_id") && !row.IsNull("class_id")) ? Convert.ToInt32(row["class_id"]) : -1;
     this.schoolId = (columns.Contains("school_id") && !row.IsNull("school_id")) ? Convert.ToInt32(row["school_id"]) : -1;
     this.teacherId = (columns.Contains("teacher_id") && !row.IsNull("teacher_id")) ? Convert.ToInt32(row["teacher_id"]) : -1;
     this.className = (columns.Contains("class_name") && !row.IsNull("class_name")) ? Convert.ToString(row["class_name"]) : "-";
     this.schoolName = (columns.Contains("school_name") && !row.IsNull("school_name")) ? Convert.ToString(row["school_name"]) : "-";
     this.teacherName = (columns.Contains("teacher") && !row.IsNull("teacher")) ? Convert.ToString(row["teacher"]) : "-";
 }
开发者ID:idurlen92,项目名称:E_Grader,代码行数:10,代码来源:ClassInSchoolObject.cs

示例5: UserObject

        public UserObject(DataColumnCollection columns, DataRow row)
        {
            this.id = columns.Contains("id") ? Convert.ToInt32(row["id"]) : -1;
            this.classId = (columns.Contains("class_id") && !row.IsNull("class_id")) ? Convert.ToInt32(row["class_id"]) : -1;
            this.userTypeId = columns.Contains("user_type_id") ? Convert.ToInt32(row["user_type_id"]) : -1;
            this.worksIn = (columns.Contains("works_in") && !row.IsNull("works_in")) ? Convert.ToInt32(row["works_in"]) : -1;

            this.name = columns.Contains("name") ? Convert.ToString(row["name"]) : "-";
            this.lastname = columns.Contains("lastname") ? Convert.ToString(row["lastname"]) : "-";
            this.username = columns.Contains("username") ? Convert.ToString(row["username"]) : "-";
            this.password = columns.Contains("password") ? Convert.ToString(row["password"]) : "-";

            String userType = columns.Contains("user_type_name") ? Convert.ToString(row["user_type_name"]) : "-";
            if (userType.ToLower().Contains("admin"))
                this.userType = UserType.Admin;
            else
                this.userType = (userType.Contains("student") ? UserType.Student : UserType.Teacher);
        }
开发者ID:idurlen92,项目名称:E_Grader,代码行数:18,代码来源:UserObject.cs

示例6: GradeObject

        public GradeObject(DataColumnCollection columns, DataRow row)
        {
            this.grade = columns.Contains("grade") ? Convert.ToInt32(row["grade"]) : -1;
            this.rubricId = columns.Contains("rubric_id") ? Convert.ToInt32(row["rubric_id"]) : -1;
            this.studentId = columns.Contains("student_id") ? Convert.ToInt32(row["student_id"]) : -1;
            this.teacherId = columns.Contains("teacher_id") ? Convert.ToInt32(row["teacher_id"]) : -1;
            this.date = (columns.Contains("date") && !row.IsNull("date")) ? Convert.ToString(row["date"]) : "-";
            this.note = (columns.Contains("note") && !row.IsNull("note")) ? Convert.ToString(row["note"]) : "-";

            if (!this.date.Equals("-"))
                this.date = this.date.Substring(0, this.date.IndexOf(' ') + 1);
        }
开发者ID:idurlen92,项目名称:E_Grader,代码行数:12,代码来源:GradeObject.cs

示例7: InsertAfter

        public void InsertAfter(DataColumnCollection columns, DataColumn currentColumn, DataColumn newColumn)
        {
            if (columns.Contains(currentColumn.ColumnName))
            {
                columns.Add(newColumn);
                //add the new column after the current one 
                columns[newColumn.ColumnName].SetOrdinal(currentColumn.Ordinal + 1);
            }
            else
            {

            }
        }
开发者ID:HarryiCalc,项目名称:Test-Phakisa,代码行数:13,代码来源:scrEngineering.cs

示例8: CheckAndShowSupportContinuer

        /// <summary>
        /// 检查并显示是否支持继续分析的功能
        /// </summary>
        /// <param name="columns"></param>
        private void CheckAndShowSupportContinuer(DataColumnCollection columns)
        {
            string msg = "";
            //↓判断是否有上次分析日期
            if (!columns.Contains("上次分析日期"))
                msg += "[上次分析日期]";
            if (!columns.Contains("是否完成"))
                if (string.IsNullOrEmpty(msg))
                    msg += "[是否完成]";
                else
                    msg += ",[是否完成]";

            m_SupportContinute = string.IsNullOrEmpty(msg);

            if (!m_SupportContinute)
                MsgBox.Show(1, string.Format("检测到Excel文件中缺少{0}列,将不支持断点分析。\r\n如果需要支持断点分析,请手动添加{0}列。", msg));
        }
开发者ID:StephenYang1989,项目名称:AliSearchAnalysis,代码行数:21,代码来源:FrmSearchRanking.cs

示例9: AddColumn

        /// <summary>
        /// Adds a new <c>DataColumn</c> to the given collection.
        /// </summary>
        /// <remarks>
        /// The new <c>DataColumn</c> is contructed from the remaining
        /// arguments.
        /// </remarks>
        /// <param name="columns">
        /// The collection to which to add the new column.
        /// </param>
        /// <param name="defaultValue">
        /// The new column's default value
        /// </param>
        /// <param name="name">
        /// The name of the new column.  If a column with the same name
        /// pre-exists in the collection, this operation does nothing.
        /// </param>
        /// <param name="type">
        /// The System.Type of the new column's values.
        /// </param>
        internal static void AddColumn(
            DataColumnCollection columns,
            object defaultValue,
            string name,
            Type type)
        {
            if (columns.Contains(name))
            {
                return;
            }

            DataColumn column = new DataColumn(name, type);

            if (defaultValue != null)
            {
                column.DefaultValue = defaultValue;
            }

            columns.Add(column);
        }
开发者ID:plusql,项目名称:hsqldb-snapshot-20160112,代码行数:40,代码来源:HsqlResultSetMetaData.cs

示例10: ConvertColumnNames

        private static void ConvertColumnNames(DataColumnCollection AColumns)
        {
            foreach (DataColumn col in AColumns)
            {
                string colName = StringHelper.UpperCamelCase(col.ColumnName, true, true);

                if (AColumns.Contains(colName))
                {
                    // this column is not unique. happens in p_recent_partner, columns p_when_d and p_when_t
                    colName = StringHelper.UpperCamelCase(col.ColumnName, true, false);
                }

                col.ColumnName = colName;
            }
        }
开发者ID:js1987,项目名称:openpetragit,代码行数:15,代码来源:ImportExport.cs

示例11: ImportRow

        private static StatusMessage ImportRow(DataRow row, LocationType LocType, int GeocodeCount, DataColumnCollection ImportColumns, out int geocodeCountReturn)
        {
            string locName = row.Field<string>("LocationName");

            var ReturnMsg = new StatusMessage();
            ReturnMsg.ObjectName = locName;
            ReturnMsg.Success = true;
            var Msg = new StringBuilder();
            var geocodeCountNew = GeocodeCount;

            //Create new Location for row
            var newLoc = new Location(locName, LocType.Key);
            Repositories.LocationRepo.Insert(newLoc);

            try
            {
                //Default Props
                var locationTypeService = new LocationTypeService();
                var defaultLocType = locationTypeService.GetLocationType(Constants.DefaultLocationTypeKey);
                foreach (var prop in defaultLocType.Properties)
                {
                    string colName = prop.Alias;
                    if (ImportColumns.Contains(colName))
                    {
                        newLoc.AddPropertyData(colName, row.Field<object>(colName));
                    }
                    else
                    {
                        newLoc.AddPropertyData(colName, null);
                        Msg.AppendLine(string.Concat("Data for '", colName, "' was not included in the import file."));
                    }
                }

                //Custom Props
                if (LocType.Key != defaultLocType.Key)
                {
                    foreach (var prop in LocType.Properties)
                    {
                        string colName = prop.Alias;

                        if (ImportColumns.Contains(colName))
                        {
                            newLoc.AddPropertyData(colName, row.Field<object>(colName));
                        }
                        else
                        {
                            newLoc.AddPropertyData(colName, null);
                            Msg.AppendLine(string.Concat("Data for '", colName, "' was not included in the import file."));
                        }
                    }
                }

                // SAVE properties of new location to db
                try
                {
                    Repositories.LocationRepo.Update(newLoc);
                }
                catch (Exception eSave)
                {
                    ReturnMsg.Success = false;
                    ReturnMsg.RelatedException = eSave;
                    ReturnMsg.Code = ReturnMsg.Code != "" ? ReturnMsg.Code + ",InsertError" : "InsertError";
                    Msg.AppendLine("There was a problem saving the new location data.");
                }

                //Check for Lat/Long values - import if present
                if (ImportColumns.Contains("Latitude"))
                {
                    int convertedInt = 0;
                    Int32.TryParse(row.Field<string>("Latitude"), out convertedInt);
                    newLoc.Latitude = convertedInt;
                }

                if (ImportColumns.Contains("Longitude"))
                {
                    int convertedInt = 0;
                    Int32.TryParse(row.Field<string>("Longitude"), out convertedInt);
                    newLoc.Longitude = convertedInt;
                }

                //If Lat/Long are both 0... attempt geocoding
                if (newLoc.Latitude == 0 && newLoc.Longitude == 0)
                {
                    //TODO: make dynamic based on provider limit
                    if (GeocodeCount >= MAX_GEOCODE)
                    {
                        ReturnMsg.Success = true;
                        ReturnMsg.Code = "GeocodingProblem";
                        Msg.AppendLine(
                            "This address exceeded the limits for geo-coding in a batch. Please run maintenance to update geo-codes later.");
                    }
                    else
                    {
                        try
                        {
                            var newCoordinate = DoGeocoding.GetCoordinateForAddress(newLoc.Address);
                            newLoc.Latitude = newCoordinate.Latitude;
                            newLoc.Longitude = newCoordinate.Longitude;

                            geocodeCountNew++;
//.........这里部分代码省略.........
开发者ID:ismailmayat,项目名称:uLocate,代码行数:101,代码来源:Import.cs

示例12: ClassObject

 public ClassObject(DataColumnCollection columns, DataRow row)
 {
     this.id = columns.Contains("id") ? Convert.ToInt32(row["id"]) : -1;
     this.className = columns.Contains("class_name") ? Convert.ToString(row["class_name"]) : "-";
 }
开发者ID:idurlen92,项目名称:E_Grader,代码行数:5,代码来源:ClassObject.cs

示例13: GetColumnName

 static String GetColumnName(DataColumnCollection cols, string colName, int deep = 0)
 {
     string tem = colName;
     tem = colName + (deep == 0 ? "" : deep.ToString());
     if (cols.Contains(tem))
     {
         return GetColumnName(cols, colName, ++deep);
     }
     return tem;
 }
开发者ID:BachelorEric,项目名称:ModelFirst,代码行数:10,代码来源:ExcelHelper.cs


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