private void button1_Click(object sender, EventArgs e) { try { DataSetTypes changes = (DataSetTypes)dataSetTypes.GetChanges(); if (changes == null) { return; } DataTable dt = changes.tblTypes.GetChanges(); DataRow[] badRows = dt.GetErrors(); if (badRows.Length > 0) { string errorMsg = ""; foreach (DataRow row in badRows) { foreach (DataColumn col in row.GetColumnsInError()) { errorMsg = errorMsg + row.GetColumnsInError() + "\n"; } } MessageBox.Show("Errors in data: " + errorMsg, "Please fix", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int numRows = tblTypesTableAdapter.Update(changes); MessageBox.Show("Updated " + numRows + " rows", "Success"); dataSetTypes.AcceptChanges(); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Erros", MessageBoxButtons.OK, MessageBoxIcon.Error); dataSetTypes.RejectChanges(); } }
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) { if (data == null) { return(base.VisitPropertyDeclaration(propertyDeclaration, null)); } // look for property to return generic DbSet type var memberType = propertyDeclaration.ReturnType as MemberType; if (memberType == null || !DataSetTypes.Contains(memberType.MemberName)) { return(base.VisitPropertyDeclaration(propertyDeclaration, data)); } // get the first generic type var entityType = memberType.TypeArguments .OfType <MemberType>() .FirstOrDefault(); if (entityType == null) { return(base.VisitPropertyDeclaration(propertyDeclaration, data)); } var entitySet = new ParsedEntitySet { EntityClass = entityType.MemberName, ContextProperty = propertyDeclaration.Name }; ParsedContext.Properties.Add(entitySet); return(base.VisitPropertyDeclaration(propertyDeclaration, data)); }
public virtual void Copy(DataRecord <T> rhs) { mDataSetType = rhs.mDataSetType; mLabel = rhs.mLabel; mPredictedLabel = rhs.mPredictedLabel; mTag = rhs.mTag; }
private void ParseProperty(PropertyDeclarationSyntax node) { var returnType = node.Type .DescendantNodesAndSelf() .OfType <GenericNameSyntax>() .FirstOrDefault(); // expecting generic return type with 1 argument if (returnType == null || returnType.TypeArgumentList.Arguments.Count != 1) { return; } var returnName = returnType.Identifier.ValueText; if (!DataSetTypes.Contains(returnName)) { return; } var firstArgument = returnType .TypeArgumentList .Arguments .FirstOrDefault(); // last identifier is class name var className = firstArgument .DescendantNodesAndSelf() .OfType <IdentifierNameSyntax>() .Select(s => s.Identifier.ValueText) .LastOrDefault(); var propertyName = node.Identifier.ValueText; if (string.IsNullOrEmpty(className) || string.IsNullOrEmpty(propertyName)) { return; } if (ParsedContext == null) { ParsedContext = new ParsedContext { ContextClass = _currentClass } } ; var entitySet = new ParsedEntitySet { EntityClass = className, ContextProperty = propertyName }; ParsedContext.Properties.Add(entitySet); } }
private List <CDataRecord> LoadDataSet(DataSetTypes dstype) { List <CDataRecord> data_set = new List <CDataRecord>(); foreach (ListViewItem item in lvTabularData.Items) { CDataRecord rec = item.Tag as CDataRecord; if (rec.DataSetType == dstype) { data_set.Add(rec); } } return(data_set); }