private MappingData GetMapping(Type ownerType, VariableSchema schema) { var key = Tuple.Create(ownerType, schema); var version = schema != null ? schema.Version : 0; if (!_mappingDatas.TryGetValue(key, out var data) || data.Map.Version != version) { if (data == null) { data = new MappingData { Properties = GetPropertyMaps(ownerType) }; _mappingDatas.Add(key, data); } data.Map = new VariableMap(version); foreach (var propertyMap in data.Properties) { data.Map.Add(propertyMap); } if (schema != null) { data.Map.Add(schema); } } return(data); }
/// <summary> /// Builds a strongly typed Entity Model based on a given DXA R2 Data Model. /// </summary> /// <param name="entityModel">The strongly typed Entity Model to build. Is <c>null</c> for the first Entity Model Builder in the pipeline.</param> /// <param name="entityModelData">The DXA R2 Data Model.</param> /// <param name="baseModelType">The base type for the Entity Model to build.</param> /// <param name="localization">The context <see cref="Localization"/>.</param> public void BuildEntityModel(ref EntityModel entityModel, EntityModelData entityModelData, Type baseModelType, Localization localization) { using (new Tracer(entityModel, entityModelData, baseModelType, localization)) { Common.Models.MvcData mvcData = CreateMvcData(entityModelData.MvcData, "Entity"); SemanticSchema semanticSchema = SemanticMapping.GetSchema(entityModelData.SchemaId, localization); Type modelType = (baseModelType == null) ? ModelTypeRegistry.GetViewModelType(mvcData) : semanticSchema.GetModelTypeFromSemanticMapping(baseModelType); MappingData mappingData = new MappingData { SourceViewModel = entityModelData, ModelType = modelType, SemanticSchema = semanticSchema, Fields = entityModelData.Content, MetadataFields = entityModelData.Metadata, Localization = localization }; entityModel = (EntityModel)CreateViewModel(mappingData); entityModel.Id = entityModelData.Id; entityModel.MvcData = mvcData ?? entityModel.GetDefaultView(localization); } }
public MappingCreationContext WithToTargetDataSource(IDataSource dataSource) { var newSourceMappingData = MappingData.WithToTargetSource(dataSource.SourceMember); var isAlternate = !dataSource.IsSequential; var newContext = new MappingCreationContext(newSourceMappingData) { InstantiateLocalVariable = isAlternate }; var newMapperData = newContext.MapperData; newMapperData.SourceObject = dataSource.Value; newMapperData.TargetObject = MapperData.TargetObject; if (TargetMember.IsComplex) { if (isAlternate) { newMapperData.LocalVariable = MapperData.LocalVariable; } newMapperData.TargetInstance = MapperData.TargetInstance; } else if (TargetMember.IsEnumerable) { UpdateEnumerableVariablesIfAppropriate(MapperData, newMapperData); } return(newContext); }
public List <EquipmentItem> FliterByGroupEquipment(GroupEQuipment _group) { List <EquipmentItem> _newList = new List <EquipmentItem>(); _mapBagToFliter.Clear(); List <TypeEquipmentCharacter> _listTypeFlit = MappingData.GetListTypeEquiptmentByGroup(_group); int count = 0; if (_group == GroupEQuipment.Equipment) { _myItems.ForEach((EquipmentItem item) => { if (_listTypeFlit.Contains(item.typeItem)) { _mapBagToFliter.Add(count, _newList.Count); _newList.Add(item); } count++; }); } //else if (_group == GroupEQuipment.Runestone) //{ // List<Item> _newList = new List<Item>(); // SplitDataFromServe._listGemInBag.ForEach((Item item) => // { // //if (_listTypeFlit.Contains(item.typeItem)) // { // _mapBagToFliter.Add(count, _newList.Count); // _newList.Add(item); // } // count++; // }); //} return(_newList); }
private void btnReverse_Click(object sender, EventArgs e) { DataGridViewSelectedCellCollection selectedcells = this.dataGridViewMapping.SelectedCells; List <int> indexs = new List <int>(); for (int i = 0; i < selectedcells.Count; i++) { indexs.Add(selectedcells[i].RowIndex); } indexs = indexs.Distinct().ToList(); for (int i = 0; i < indexs.Count; i++) { int idx = indexs[i]; MappingData md = this.MappingList[idx]; string temp = md.ToType; md.ToType = md.FromType; md.FromType = temp; temp = md.ToName; md.ToName = md.FromName; md.FromName = temp; } this.dataGridViewMapping.DataSource = null; this.dataGridViewMapping.DataSource = this.MappingList; this.SetMappingColumns(); for (int i = 0; i < indexs.Count; i++) { this.dataGridViewMapping.Rows[indexs[i]].Selected = true; } }
/// <summary> /// Gets the mappings for the specified entity and worksheet /// </summary> /// <returns></returns> public Message GetEntityMappings() { Message responseMsg = null; ImportUtilities importUtility = new ImportUtilities(); SPDataAccess spDataAccess = new SPDataAccess(); MappedColumns mappedColumns = new MappedColumns(); WorksheetUtilities worksheetUtilities = new WorksheetUtilities(spDataAccess); MappingData mappingData = this.ValidateRequest(spDataAccess, false); // get the columns from the supplied worksheet mappedColumns.WSColumns = worksheetUtilities.GetWorksheetColumns(mappingData); // checks to see if the columns pulled from sheet map to // a predefined template e.g. Bulk Import or Goals Export mappedColumns.TemplateType = ImportUtilities.GetImportTemplateType(mappedColumns.WSColumns); // get the entity columns with the default values for choice columns mappedColumns.ColumnDefinitions = importUtility.GetEntityColumnDefaultValues(spDataAccess, mappingData.ListName); responseMsg = ctx.CreateJsonResponse <MappedColumns>(mappedColumns); return(responseMsg); }
void CaculateIndexAfterReinforce() { if (isSpecialUpgrade) { if (_mainEquip.typeItem == TypeEquipmentCharacter.Avatar) { int _newLevel = _mainEquip.levelUpgraded + 1; _newEquipAfterUpgrade.setValue("39", _newLevel * 0.02f); _newEquipAfterUpgrade.setValue("98", _newLevel * 0.01f); _newEquipAfterUpgrade.setValue("99", _newLevel * 0.01f); _newEquipAfterUpgrade.setValue("100", _newLevel * 0.005f); _newEquipAfterUpgrade.setValue("101", _newLevel * 0.005f); _newEquipAfterUpgrade.setValue("999", (_newLevel - 1) / 2 + 1); } else { int _idAttribute = MappingData.ConvertIdBuffToAttribute(_mainEquip.idItemInit); _tempValueIndex = float.Parse(_mainEquip.getValue(_idAttribute.ToString()).ToString()); _newEquipAfterUpgrade.setValue(_idAttribute.ToString(), _tempValueIndex + (_mainEquip.idItemInit <= 8 ? 0.05f : 0.1f)); } } for (int i = 1; i <= 28; i++) { _tempValueIndex = float.Parse(_mainEquip.getValue(i.ToString()).ToString()); if (_tempValueIndex != 0) { _newEquipAfterUpgrade.setValue(i.ToString(), _tempValueIndex * 1.1f); } } _newEquipAfterUpgrade.levelUpgraded += 1; }
private async Task <MappingData> EnsureLoadMappingData() { if (!_cache.TryGetValue(CacheKeys.Common_EmployeeList, out MappingData data)) { data = new MappingData(); var dto = await _employeeAppService.GetCacheDataAsync(); if (dto?.Count > 0) { data.List = dto; foreach (var item in dto) { if (!string.IsNullOrEmpty(item.Number)) { data.ByNumber[item.Number] = item; } if (item.UserId.HasValue) { data.ByUserId[item.UserId.Value] = item; } data.ById[item.Id] = item; } } var cacheEntryOptions = new MemoryCacheEntryOptions() .SetAbsoluteExpiration(CacheKeys.DefaultCacheAbsoluteExpiration); _cache.Set(CacheKeys.EnterpriseContact_PositionList, data, cacheEntryOptions); } return(data); }
public MappingCreationContext WithDataSource(IDataSource newDataSource) { var newSourceMappingData = MappingData.WithSource(newDataSource.SourceMember); newSourceMappingData.MapperKey = new RootObjectMapperKey( RuleSet, newSourceMappingData.MappingTypes, new FixedMembersMembersSource(newDataSource.SourceMember, TargetMember)); var newContext = new MappingCreationContext(newSourceMappingData, mappingExpressions: MappingExpressions) { InstantiateLocalVariable = false }; newContext.MapperData.SourceObject = newDataSource.Value; newContext.MapperData.TargetObject = MapperData.TargetObject; if (TargetMember.IsComplex) { newContext.MapperData.TargetInstance = MapperData.TargetInstance; } else if (_mapperDataHasRootEnumerableVariables) { UpdateEnumerableVariables(MapperData, newContext.MapperData); } return(newContext); }
private static ViewModel CreateViewModel(MappingData mappingData) { ViewModelData viewModelData = mappingData.SourceViewModel; EntityModelData entityModelData = viewModelData as EntityModelData; ViewModel result; if (string.IsNullOrEmpty(mappingData.ModelId)) { // Use parameterless constructor result = (ViewModel)mappingData.ModelType.CreateInstance(); } else { // Pass model Identifier in constructor. result = (ViewModel)mappingData.ModelType.CreateInstance(mappingData.ModelId); } result.ExtensionData = viewModelData.ExtensionData; result.HtmlClasses = viewModelData.HtmlClasses; result.XpmMetadata = viewModelData.XpmMetadata; MediaItem mediaItem = result as MediaItem; if (mediaItem != null) { BinaryContentData binaryContent = entityModelData?.BinaryContent; if (binaryContent == null) { throw new DxaException( $"Unable to create Media Item ('{mappingData.ModelType.Name}') because the Data Model '{entityModelData?.Id}' does not contain Binary Content Data." ); } mediaItem.Url = binaryContent.Url; mediaItem.FileName = binaryContent.FileName; mediaItem.MimeType = binaryContent.MimeType; mediaItem.FileSize = binaryContent.FileSize; } EclItem eclItem = result as EclItem; if (eclItem != null) { ExternalContentData externalContent = entityModelData.ExternalContent; if (externalContent == null) { throw new DxaException( $"Unable to create ECL Item ('{mappingData.ModelType.Name}') because the Data Model '{entityModelData.Id}' does not contain External Content Data." ); } eclItem.EclDisplayTypeId = externalContent.DisplayTypeId; eclItem.EclTemplateFragment = externalContent.TemplateFragment; eclItem.EclExternalMetadata = externalContent.Metadata; eclItem.EclUri = externalContent.Id; } MapSemanticProperties(result, mappingData); return(result); }
private void ReadNewBuff(EquipmentItem item, JSONNode N) { item.levelUpgraded = N["level"].AsInt; int _idRate = MappingData.ConvertIdBuffToAttribute(item.idItemInit); item.setValue(_idRate.ToString(), N["rate"].AsFloat); }
/// <summary> /// Convert the value if it is a DateTime /// </summary> /// <param name="value"></param> /// <returns></returns> //internal static string ConvertCellValueDateTime(string value) //{ // string returnValue; // // need to parse different inputs // DateTime date; // if (string.IsNullOrEmpty(value)) // returnValue = value; // if (!DateTime.TryParse(value, out date)) // { // double dateVal; // if (double.TryParse(value, out dateVal)) // date = DateTime.FromOADate(dateVal); // } // if(date == new DateTime()) // return string.Empty; // else // return date.ToString("MM/dd/yyyy hh:mm:ss tt"); //} /// <summary> /// Sets the team object and id on mapping data /// </summary> /// <param name="spDataAccess"></param> /// <param name="mappingData"></param> internal static void SetTeam(SPDataAccess spDataAccess, MappingData mappingData) { string teamName = mappingData.Mappings["KPTeam"]; Team team = spDataAccess.Teams.Find(t => t.Nick == teamName); mappingData.TeamId = team.KPID; mappingData.Team = team; }
public void LoadFile(string listName, string fileName) { MappingData mappingData = new MappingData() { LibraryName = "/Common", ListName = listName, FileName = fileName }; this.LoadFile(mappingData); }
public DataSourceFindContext GetDataSourceFindContext() { var memberMappingData = MappingData.GetChildMappingData(MemberMapperData); if (_dataSourceFindContext == null) { _dataSourceFindContext = new DataSourceFindContext(memberMappingData); } return(_dataSourceFindContext.With(memberMappingData)); }
private static object MapKeyword(KeywordModelData keywordModelData, Type targetType, Localization localization) { if (typeof(KeywordModel).IsAssignableFrom(targetType)) { KeywordModel result; if (keywordModelData.SchemaId == null) { result = new KeywordModel { ExtensionData = keywordModelData.ExtensionData }; } else { MappingData keywordMappingData = new MappingData { SourceViewModel = keywordModelData, ModelType = targetType, SemanticSchema = SemanticMapping.GetSchema(keywordModelData.SchemaId, localization), MetadataFields = keywordModelData.Metadata, Localization = localization }; result = (KeywordModel)CreateViewModel(keywordMappingData); } result.Id = keywordModelData.Id; result.Title = keywordModelData.Title; result.Description = keywordModelData.Description ?? string.Empty; result.Key = keywordModelData.Key ?? string.Empty; result.TaxonomyId = keywordModelData.TaxonomyId; return(result); } if (targetType == typeof(Tag)) { return(new Tag { DisplayText = GetKeywordDisplayText(keywordModelData), Key = keywordModelData.Key, TagCategory = localization.GetCmUri(keywordModelData.TaxonomyId, (int)ItemType.Category) }); } if (targetType == typeof(bool)) { string key = string.IsNullOrEmpty(keywordModelData.Key) ? keywordModelData.Title : keywordModelData.Key; return(Convert.ToBoolean(key)); } return(GetKeywordDisplayText(keywordModelData)); }
private static string GetLocationString(MappingData mappingData) { var builder = new StringBuilder(); builder.Append(mappingData.ShelfName); builder.Append("-r"); builder.Append(mappingData.RowBox + 1); builder.Append("-c"); builder.Append(mappingData.ColBox); return(builder.ToString()); }
public virtual MappingData GenerateMappingData() { MappingData data = new MappingData(); DbSqlQueryExpression sqlQuery = this.CreateSqlQuery(); var objectActivatorCreator = this._resultElement.MappingObjectExpression.GenarateObjectActivatorCreator(sqlQuery); data.SqlQuery = sqlQuery; data.ObjectActivatorCreator = objectActivatorCreator; return(data); }
private void RemoveUnusedMappingFields() { for (int i = MappingData.Count - 1; i >= 0; i--) { var map = MappingData[i]; if ((string.IsNullOrWhiteSpace(map.ImportColumn) || map.IsAssociation) && map.DefaultValue is null) { MappingData.Remove(map); } } }
/// <summary> /// Builds a strongly typed Page Model from a given DXA R2 Data Model. /// </summary> /// <param name="pageModel">The strongly typed Page Model to build. Is <c>null</c> for the first Page Model Builder in the pipeline.</param> /// <param name="pageModelData">The DXA R2 Data Model.</param> /// <param name="includePageRegions">Indicates whether Include Page Regions should be included.</param> /// <param name="localization">The context <see cref="Localization"/>.</param> public void BuildPageModel(ref PageModel pageModel, PageModelData pageModelData, bool includePageRegions, Localization localization) { using (new Tracer(pageModel, pageModelData, includePageRegions, localization)) { Common.Models.MvcData mvcData = CreateMvcData(pageModelData.MvcData, "Page"); Type modelType = ModelTypeRegistry.GetViewModelType(mvcData); if (modelType == typeof(PageModel)) { // Standard Page Model. pageModel = new PageModel(pageModelData.Id) { ExtensionData = pageModelData.ExtensionData, HtmlClasses = pageModelData.HtmlClasses, XpmMetadata = pageModelData.XpmMetadata, }; } else if (pageModelData.SchemaId == null) { // Custom Page Model, but no custom metadata. pageModel = (PageModel)modelType.CreateInstance(pageModelData.Id); pageModel.ExtensionData = pageModelData.ExtensionData; pageModel.HtmlClasses = pageModelData.HtmlClasses; pageModel.XpmMetadata = pageModelData.XpmMetadata; } else { // Custom Page Model with custom metadata; do full-blown model mapping. MappingData mappingData = new MappingData { SourceViewModel = pageModelData, ModelId = pageModelData.Id, ModelType = modelType, SemanticSchema = SemanticMapping.GetSchema(pageModelData.SchemaId, localization), MetadataFields = pageModelData.Metadata, Localization = localization }; pageModel = (PageModel)CreateViewModel(mappingData); } pageModel.MvcData = mvcData; pageModel.Meta = pageModelData.Meta ?? new Dictionary <string, string>(); pageModel.Title = PostProcessPageTitle(pageModelData, localization); // TODO TSI-2210: This should eventually be done in Model Service. pageModel.Url = pageModelData.UrlPath; if (pageModelData.Regions != null) { IEnumerable <RegionModelData> regions = includePageRegions ? pageModelData.Regions : pageModelData.Regions.Where(r => r.IncludePageId == null); pageModel.Regions.UnionWith(regions.Select(data => CreateRegionModel(data, localization))); } } }
private void btnAdd_Click(object sender, EventArgs e) { if (this.dataGridViewOTS.SelectedRows.Count == 0 || this.dataGridViewOPC.SelectedRows.Count == 0) { return; } int length = 0; if (this.dataGridViewOPC.SelectedRows.Count > this.dataGridViewOTS.SelectedRows.Count) // 적게 선택한쪽을 따른다. { length = this.dataGridViewOTS.SelectedRows.Count; } else { length = this.dataGridViewOPC.SelectedRows.Count; } DataGridViewSelectedRowCollection selectedots = this.dataGridViewOTS.SelectedRows; DataGridViewSelectedRowCollection selectedopc = this.dataGridViewOPC.SelectedRows; this.dataGridViewMapping.DataSource = null; try { for (int i = 0; i < length; i++) { MappingData md = new MappingData(); string otsname = this.dataGridViewOTS["Name", selectedots[i].Index].Value.ToString(); string otsparam = this.dataGridViewOTS["Param", selectedots[i].Index].Value.ToString(); string opctag = this.dataGridViewOPC["Name", selectedopc[i].Index].Value.ToString(); md.FromType = "HYSYS"; md.FromName = string.Format("{0}.{1}", otsname, otsparam); md.ToType = this.CurrentController.OPCServerName; md.ToName = string.Format("{0}", opctag); this.MappingList.Add(md); } } catch { } this.dataGridViewMapping.DataSource = this.MappingList; this.SetMappingColumns(); }
/// <summary> /// Validates the specified template with the corresponding mapping. /// TODO: should do this transparently to the user - check both template types /// and automatically set the correct template type. /// </summary> /// <param name="dtColumns"></param> /// <param name="mappingData"></param> /// <returns></returns> public static bool ValidateTemplateMapping(DataColumnCollection dtColumns, MappingData mappingData) { string ERR_REQUIRED_COLUMNS_MISSING = "{0} Column{1} {2} missing."; string PLURAL = "s"; string IS = "is"; string ARE = "are"; string errMsg = string.Empty; List <string> UPLOAD_TEMPLATE_REQUIRED_FIELDS = new List <string>() { "Team", "ID" }; List <string> missingColumns = new List <string>(); int columnsFound = 0; foreach (KeyValuePair <string, string> kvPair in mappingData.Mappings) { if (dtColumns.Contains(kvPair.Value)) { columnsFound++; } else { missingColumns.Add(kvPair.Value); } } if (mappingData.TemplateType.Equals("Export") && missingColumns.Count > 0) { List <string> requiredColumns = missingColumns.FindAll(c => UPLOAD_TEMPLATE_REQUIRED_FIELDS.Contains(c)); if (requiredColumns.Count > 0) { if (missingColumns.Count > 1) { errMsg = string.Format(ERR_REQUIRED_COLUMNS_MISSING, string.Join(", ", requiredColumns), PLURAL, ARE); } else { errMsg = string.Format(ERR_REQUIRED_COLUMNS_MISSING, string.Join(", ", requiredColumns), string.Empty, IS); } throw new RequiredKeyFieldException(errMsg); } } // calculate percentage of columns found - arbitrary at 87% //double pctFound = Convert.ToInt16(Convert.ToDouble(columnsFound) / Convert.ToDouble(mappingData.Mappings.Count) * 100); // found more than 87% of the specified columns //return (pctFound > 87); return(true); }
DbSqlQueryExpression ConvertToDbSqlQueryExpression(Expression exp, Type resultType) { if (!IsIQueryType(exp.Type)) { throw new NotSupportedException(exp.ToString()); } QueryBase query = ExpressionEvaluator.Evaluate(exp) as QueryBase; IQueryState qs = QueryExpressionVisitor.VisitQueryExpression(query.QueryExpression, this._scopeParameters, this._scopeTables); MappingData mappingData = qs.GenerateMappingData(); DbSqlQueryExpression sqlQueryExpression = mappingData.SqlQuery.Update(resultType); return(sqlQueryExpression); }
public void MappingControllerGetUsesMappingProvider() { var mock = new Mock <IMappingProvider>(); MappingData value = new MappingData(); mock.Setup(x => x.GetCurrentMapping()).Returns(value); var controller = new MappingController(mock.Object); var result = controller.Get(); var resultData = result.As <JsonResult>(); resultData.StatusCode.Should().Equals(200); resultData.Value.Should().Equals(value); }
public void ProcessFiles() { FileReaderDataAccess = new FileReaderDataAccess(); var mapGroup = MappingData.GroupBy(map => map.ExecutionType); foreach (var executionType in mapGroup) { if (executionType.Key == "L2L") { OutputTableData.AddRange(PdfL2L.ProcessData(MappingData, FileTable)); } } FileReaderDataAccess.InsertDataIntoOutputTable(OutputTableData); FileReaderDataAccess.UpdateFileTable(FileTable.FileId); }
Expression GetTableExpression(int[] index) { var data = new MappingData { MappingSchema = Parser.MappingSchema, ObjectMapper = ObjectMapper, Index = index }; return(Expression.Convert( Expression.Call(null, _mapperMethod, ExpressionParser.DataContextParam, ExpressionParser.DataReaderParam, Expression.Constant(data)), ObjectType)); }
DbCommandFactor GenerateCommandFactor() { IQueryState qs = QueryExpressionVisitor.VisitQueryExpression(this._query.QueryExpression); MappingData data = qs.GenerateMappingData(); IObjectActivator objectActivator; objectActivator = data.ObjectActivatorCreator.CreateObjectActivator(); IDbExpressionTranslator translator = this._query.DbContext._dbContextServiceProvider.CreateDbExpressionTranslator(); List <DbParam> parameters; string cmdText = translator.Translate(data.SqlQuery, out parameters); DbCommandFactor commandFactor = new DbCommandFactor(objectActivator, cmdText, parameters.ToArray()); return(commandFactor); }
private static object MapEmbeddedFields(ContentModelData embeddedFields, Type targetType, SemanticSchemaField semanticSchemaField, string contextXPath, MappingData mappingData) { MappingData embeddedMappingData = new MappingData { ModelType = targetType, SemanticSchema = mappingData.SemanticSchema, EmbeddedSemanticSchemaField = semanticSchemaField, EmbedLevel = mappingData.EmbedLevel + 1, SourceViewModel = mappingData.SourceViewModel, Fields = embeddedFields, MetadataFields = embeddedFields, ContextXPath = contextXPath, Localization = mappingData.Localization }; return(CreateViewModel(embeddedMappingData)); }
public void LoadFile(MappingData mappingData) { if (mappingData.FileName.Contains("xlsx")) { this.containsWorksheets = true; } try { //this.fileStream = spDataAccess.GetFileStream(mappingData.Team.SiteUrl, mappingData.LibraryName, mappingData.FileName); this.fileStream = spDataAccess.GetFileStream(string.Empty, mappingData.LibraryName, mappingData.FileName); } catch (Exception ex) { string errMsg = string.Format("Cannot open file: {0}/{1}; {3}", mappingData.LibraryName, mappingData.FileName, ex); throw new Exception(errMsg, ex.InnerException); } }
internal static string GetSearchQueryUrl(Publication publication, string environmentPurpose) { string publicationId = publication.Id.ToString(); MappingData mapping = TopologyManagerClient.Mappings.Expand("CdEnvironment") .Where(m => m.PublicationId == publicationId && m.EnvironmentPurpose == environmentPurpose).FirstOrDefault(); if (mapping == null || mapping.CdEnvironment == null) { return(null); } string dxaSearchQueryUrl = mapping.CdEnvironment.ExtensionProperties .Where(ep => ep.Name == "DXA.Search.QueryURL") .Select(ep => ep.Value) .FirstOrDefault(); return(dxaSearchQueryUrl); }
/// <summary> /// Get the list of team id's from the data table rows /// </summary> /// <param name="dt"></param> /// <param name="mappingData"></param> /// <returns></returns> private List <int> GetTeamIds(DataTable dt, MappingData mappingData) { // the column will be KPTeam string mappedColumn = mappingData.Mappings["KPTeam"]; // the list of id's to return List <int> teamIds = new List <int>(); foreach (DataRow row in dt.Rows) { string teamName = row[mappedColumn].ToString(); Team team = this.domainManager.User.Teams.Find(t => t.Nick == teamName); // only want to add them once if (team != null && !teamIds.Contains(team.KPID)) { teamIds.Add(team.KPID); } } return(teamIds); }