//string ReadFileFromAssembly(string filename) //{ // string filecontents = String.Empty; // Assembly assem = System.Reflection.Assembly.GetCallingAssembly(); // Stream stream = assem.GetManifestResourceStream(filename); // if (stream != null) // { // StreamReader tr = new StreamReader(stream); // filecontents = tr.ReadToEnd(); // tr.Close(); // stream.Close(); // } // return filecontents; //} static void PopulateDatasetList(SasServer ss, string libname) { ADODB.Recordset adorecordset = new ADODB.RecordsetClass(); ADODB.Connection adoconnect = new ADODB.ConnectionClass(); try { adoconnect.Open("Provider=sas.iomprovider.1; SAS Workspace ID=" + ss.Workspace.UniqueIdentifier, "", "", 0); // use the SASHELP.VMEMBER view to get names of all of the datasets and views in the specified library string selectclause = "select memname, memtype from sashelp.vmember where libname='" + libname + "' and memtype in ('DATA', 'VIEW')"; adorecordset.Open(selectclause, adoconnect, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText); OleDbDataAdapter da = new OleDbDataAdapter(); DataSet ds = new DataSet(); da.Fill(ds, adorecordset, "data"); } catch { } finally { adoconnect.Close(); } }
// read list of catalog entries for the given catalog private void PopulateMembers(string lib, string cat) { Cursor c = Cursor.Current; Cursor.Current = Cursors.WaitCursor; lvMembers.BeginUpdate(); lvMembers.Items.Clear(); SAS.Workspace ws = null; try { ws = consumer.Workspace(currentServer) as SAS.Workspace; } catch (Exception ex) { throw new System.Exception("ISASTaskConsumer.Workspace is not usable!", ex); } if (currentServer.Length > 0 && ws != null) { // use the SAS IOM OLEDB provider to read data from the SAS workspace ADODB.Recordset adorecordset = new ADODB.RecordsetClass(); ADODB.Connection adoconnect = new ADODB.ConnectionClass(); try { adoconnect.Open("Provider=sas.iomprovider.1; SAS Workspace ID=" + ws.UniqueIdentifier, "", "", 0); // use the SASHELP.VCATALG view to get all of the catalog entries in the specified library/catalog string selectclause = "select * from sashelp.vcatalg where libname='" + lib + "' and memname = '" + cat + "'"; adorecordset.Open(selectclause, adoconnect, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText); while (!adorecordset.EOF) { ListViewItem lvi = new ListViewItem(); lvi.Text = adorecordset.Fields["objname"].Value.ToString(); lvi.SubItems.Add(adorecordset.Fields["objtype"].Value.ToString()); lvi.SubItems.Add(adorecordset.Fields["objdesc"].Value.ToString()); lvi.SubItems.Add(ConvertSASDate(adorecordset.Fields["created"].Value.ToString())); lvi.SubItems.Add(ConvertSASDate(adorecordset.Fields["modified"].Value.ToString())); lvi.ImageIndex = GetImageIndexForEntry(adorecordset.Fields["objtype"].Value.ToString()); lvi.Tag = string.Format("{0}.{1}.{2}.{3}", lib, cat, lvi.Text, adorecordset.Fields["objtype"].Value.ToString()); lvMembers.Items.Add(lvi); adorecordset.MoveNext(); } } catch {} finally { adoconnect.Close(); } } lvMembers.EndUpdate(); Cursor.Current = c; UpdateToolbar(); }
// read list of catalogs for the given library (in the tree node) private void PopulateCatalogs(TreeNode tn) { Cursor c = Cursor.Current; Cursor.Current = Cursors.WaitCursor; tvLibsCats.BeginUpdate(); if (tn != null) { SAS.Workspace ws = null; try { ws = consumer.Workspace(currentServer) as SAS.Workspace; } catch (Exception ex) { throw new System.Exception("ISASTaskConsumer.Workspace is not usable!", ex); } if (currentServer.Length > 0 && ws != null) { // use the SAS IOM OLEDB provider to read data from the SAS workspace ADODB.Recordset adorecordset = new ADODB.RecordsetClass(); ADODB.Connection adoconnect = new ADODB.ConnectionClass(); try { adoconnect.Open("Provider=sas.iomprovider.1; SAS Workspace ID=" + ws.UniqueIdentifier, "", "", 0); // use the SASHELP.VMEMBER view to get names of all of the catalogs in the specified library string selectclause = "select memname from sashelp.vmember where libname='" + tn.Text + "' and memtype in ('CATALOG')"; adorecordset.Open(selectclause, adoconnect, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText); while (!adorecordset.EOF) { TreeNode cat = tn.Nodes.Add(adorecordset.Fields["memname"].Value.ToString()); cat.ImageIndex = (int)CatImages.Catalog; cat.SelectedImageIndex = (int)CatImages.Catalog; cat.Tag = "CATALOG"; adorecordset.MoveNext(); } } catch {} finally { adoconnect.Close(); } } } tvLibsCats.EndUpdate(); Cursor.Current = c; UpdateToolbar(); }
private void LoadADO() { // load ADO recordset from file ADODB.Recordset rs = new ADODB.RecordsetClass(); rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient; rs.Open(_rsFileName, "Provider=MSPersist;", ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic, 0); // use ADO recordset as report data source _c1r.DataSource.Recordset = new ADOReportSource(rs); }
private static object GetSingleValue(CDNBase.AdoSession sesja, string query, bool configCnn) { ADODB.Connection cn = configCnn ? sesja.ConfigConnection : sesja.Connection; ADODB.Recordset rs = new ADODB.RecordsetClass(); rs.Open(query, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, 1); if (rs.RecordCount > 0) { return(rs.Fields[0].Value); } else { return(null); } }
// Przyk³ad 7. - Dogenerowanie WZ do FA protected static void Dogenerowanie_WZ_Do_FA() { CDNBase.AdoSession Sesja = Login.CreateSession(); //ADODB.Connection cnn = new ADODB.ConnectionClass(); ADODB.Connection cnn = Sesja.Connection; //cnn.Open( cnn.ConnectionString, "", "", 0); ADODB.Recordset rRs = new ADODB.RecordsetClass(); string select = "select top 1 TrN_TrNId as ID from cdn.TraNag where TrN_Rodzaj = 302000 "; rRs.Open(select, cnn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, 1); // Wykreowanie obiektu serwisu: CDNHlmn.SerwisHaMag Serwis = (CDNHlmn.SerwisHaMag)Sesja.CreateObject("Cdn.SerwisHaMag", null); // Samo gemerowanie dok. FA int MAGAZYN_ID = 1; Serwis.AgregujDokumenty(302, rRs, MAGAZYN_ID, 306, null); //Zapisujemy Sesja.Save(); }
public DataTable GetViewData(string connectionString, ViewSchema view) { string sqlstring = @" SELECT * FROM " + view.Name; ADODB.Connection cn = new ADODB.ConnectionClass(); cn.Open(connectionString, null, null, 0); ADODB.Recordset rs = new ADODB.RecordsetClass(); rs.Open(sqlstring, cn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, 0); OleDbDataAdapter dataAdapter = new OleDbDataAdapter(); DataTable viewData = new DataTable(); dataAdapter.Fill(viewData, rs); rs.Close(); cn.Close(); return(viewData); }
private void Form2_Load(object sender, System.EventArgs e) { ADODB.RecordsetClass rs = new ADODB.RecordsetClass(); ADODB.ConnectionClass cn = new ADODB.ConnectionClass(); cn.Open("Provider=MSOLAP; Datasource=LocalHost; Initial Catalog=FoodMart 2000","sa","",(int)ADODB.ConnectOptionEnum.adConnectUnspecified); rs.ActiveConnection=cn; rs.Open("select Order({[Store].Members},PROFIT,desc) on rows, {Crossjoin({[All products]},{ [Store Cost],[Store Sales]})} on columns from Sales ",cn,ADODB.CursorTypeEnum.adOpenDynamic ,ADODB.LockTypeEnum.adLockUnspecified,1); MessageBox.Show(rs.Fields[0].Name); MessageBox.Show(rs.GetString(ADODB.StringFormatEnum.adClipString ,rs.RecordCount," ","\n","<null>")); //object obj = rs.GetRows(-1,1,null); // rs.MoveFirst(); // String str=string.Empty; // while(rs.EOF) // { // foreach(ADODB.Field f in rs.Fields ) // { // str += f.Value ; // // } // str +="\n"; // rs.MoveNext(); // } //MessageBox.Show(str); }
private void Form2_Load(object sender, System.EventArgs e) { ADODB.RecordsetClass rs = new ADODB.RecordsetClass(); ADODB.ConnectionClass cn = new ADODB.ConnectionClass(); cn.Open("Provider=MSOLAP; Datasource=LocalHost; Initial Catalog=FoodMart 2000", "sa", "", (int)ADODB.ConnectOptionEnum.adConnectUnspecified); rs.ActiveConnection = cn; rs.Open("select Order({[Store].Members},PROFIT,desc) on rows, {Crossjoin({[All products]},{ [Store Cost],[Store Sales]})} on columns from Sales ", cn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockUnspecified, 1); MessageBox.Show(rs.Fields[0].Name); MessageBox.Show(rs.GetString(ADODB.StringFormatEnum.adClipString, rs.RecordCount, " ", "\n", "<null>")); //object obj = rs.GetRows(-1,1,null); // rs.MoveFirst(); // String str=string.Empty; // while(rs.EOF) // { // foreach(ADODB.Field f in rs.Fields ) // { // str += f.Value ; // // } // str +="\n"; // rs.MoveNext(); // } //MessageBox.Show(str); }
/* * Logs a user in when they click the login button. * ANDREAS--------------------- * */ private void loginButton_Click(object sender, EventArgs e) { //Console.WriteLine("button has been pressed"); MySqlCommand cmd = null; MySqlConnection cn = null; MySqlDataReader dr = null; //if the button is currently used to log a user in... if (buttonIsLogin) { //When we have the login db done, check the username/password combo vs the //database. Remove the dummy checks when you add the database checks. If the username //or password is wrong, clear the textfields and bring up a popup like is already done below. //also when they login, change the 'buttonIsLogin' variable to false, so the button changes to logout. //Change the userTypeBox to reflect the current level of access the login has. //(this means the query should check the successfully logged in user in the database //and see what type they are [manager, employee, or customer] to display) adodb = new ADODB.ConnectionClass(); try { //get user's input currentUserEmail = emailBox.Text; currentUserPassword = passwordBox.Text; // Console.WriteLine("u: "+currentUserEmail); // Console.WriteLine("p: "+currentUserPassword); string sql = "select ID from USER_INFO where Email='" + currentUserEmail + "' and Password ='******'"; // Console.WriteLine("sql=" + sql); adodb.Open("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source='Login.mdb';", "", "", 0); // Console.WriteLine("connected to login db"); recset = new ADODB.RecordsetClass(); // Console.WriteLine("recset obj created"); recset.Open(sql, adodb, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, 0); //System.Runtime.InteropServices.COMException // Console.WriteLine("recset opened"); //if recordset is empty the user name and password combination does not exist (see the sql statement) //else record is found if (recset.EOF) { MessageBox.Show("Invalid user name or password.", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); clearForm(); } else { // Console.WriteLine("in the else statement"); //assign the user's id to a variable string id = recset.Fields["ID"].Value.ToString(); Console.WriteLine("valid user with ID: " + id); // connection to the MySql database starts here cn = new MySqlConnection();//MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll // Console.WriteLine("sql connection instantiated"); cn.ConnectionString = MyConString; // Console.WriteLine("sonnection string created"); cn.Open(); // Console.WriteLine("connection to sql opened"); // checking user type starts here cmd = cn.CreateCommand(); // Console.WriteLine("sql command instantiated"); cmd.CommandText = "select ID from Manager where ID=" + id; // Console.WriteLine("sql statement assigned to cmd"); dr = cmd.ExecuteReader(); // Console.WriteLine("sql statement executed via datareader"); bool manager = false; //true if such record exists wich means that he is an employee if (dr.Read()) { // Console.WriteLine("person is manager"); showForm("Manager"); populateQueueList(); userTypeBox.Text = "Manager"; buttonIsLogin = false; loginButton.Text = "Log out"; manager = true; }//otherwise it ignores it and checks the other two alternatives dr.Close(); if (manager == false) { cmd = null; cmd = cn.CreateCommand(); //change the statement so we can check if he is a manager cmd.CommandText = "select ID from Employee where ID=" + id; // Console.WriteLine("new sql that checks manager"); dr = cmd.ExecuteReader(); // Console.WriteLine("execute new manager statement"); // true if such record exists which means that he is a manager if (dr.Read()) { // Console.WriteLine("person is employee"); showForm("Employee"); populateQueueList(); userTypeBox.Text = "Employee"; buttonIsLogin = false; loginButton.Text = "Log out"; } else // otherwise he is a customer { // Console.WriteLine("person is customer"); showForm("Customer"); populateQueueList(); fillPersonalInfoForCustomer(); userTypeBox.Text = "Customer"; buttonIsLogin = false; loginButton.Text = "Log out"; } } dr.Close(); cn.Close(); }// end of else statement } catch (Exception ex) { Console.WriteLine(ex.Message);//better message box? } } else { //(Don't need to change this part) //button is being used to log out, so log out when you press it... buttonIsLogin = true; loginButton.Text = "Log in"; showForm("Login"); clearForm(); currentUserEmail = ""; } }
// read list of catalog entries for the given catalog private void PopulateMembers(string lib, string cat) { Cursor c = Cursor.Current; Cursor.Current = Cursors.WaitCursor; lvMembers.BeginUpdate(); lvMembers.Items.Clear(); SAS.Workspace ws = null; try { ws = consumer.Workspace(currentServer) as SAS.Workspace; } catch (Exception ex) { throw new System.Exception("ISASTaskConsumer.Workspace is not usable!",ex); } if (currentServer.Length>0 && ws!=null) { // use the SAS IOM OLEDB provider to read data from the SAS workspace ADODB.Recordset adorecordset = new ADODB.RecordsetClass(); ADODB.Connection adoconnect = new ADODB.ConnectionClass(); try { adoconnect.Open("Provider=sas.iomprovider.1; SAS Workspace ID=" + ws.UniqueIdentifier, "", "", 0); // use the SASHELP.VCATALG view to get all of the catalog entries in the specified library/catalog string selectclause = "select * from sashelp.vcatalg where libname='" + lib + "' and memname = '" + cat + "'"; adorecordset.Open( selectclause, adoconnect, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, (int) ADODB.CommandTypeEnum.adCmdText); while (!adorecordset.EOF) { ListViewItem lvi = new ListViewItem(); lvi.Text = adorecordset.Fields["objname"].Value.ToString(); lvi.SubItems.Add(adorecordset.Fields["objtype"].Value.ToString()); lvi.SubItems.Add(adorecordset.Fields["objdesc"].Value.ToString()); lvi.SubItems.Add(ConvertSASDate(adorecordset.Fields["created"].Value.ToString())); lvi.SubItems.Add(ConvertSASDate(adorecordset.Fields["modified"].Value.ToString())); lvi.ImageIndex = GetImageIndexForEntry(adorecordset.Fields["objtype"].Value.ToString()); lvi.Tag = string.Format("{0}.{1}.{2}.{3}", lib, cat, lvi.Text, adorecordset.Fields["objtype"].Value.ToString()); lvMembers.Items.Add(lvi); adorecordset.MoveNext(); } } catch {} finally { adoconnect.Close(); } } lvMembers.EndUpdate(); Cursor.Current = c; UpdateToolbar(); }
// read list of catalogs for the given library (in the tree node) private void PopulateCatalogs(TreeNode tn) { Cursor c = Cursor.Current; Cursor.Current = Cursors.WaitCursor; tvLibsCats.BeginUpdate(); if (tn!=null) { SAS.Workspace ws = null; try { ws = consumer.Workspace(currentServer) as SAS.Workspace; } catch (Exception ex) { throw new System.Exception("ISASTaskConsumer.Workspace is not usable!",ex); } if (currentServer.Length>0 && ws!=null) { // use the SAS IOM OLEDB provider to read data from the SAS workspace ADODB.Recordset adorecordset = new ADODB.RecordsetClass(); ADODB.Connection adoconnect = new ADODB.ConnectionClass(); try { adoconnect.Open("Provider=sas.iomprovider.1; SAS Workspace ID=" + ws.UniqueIdentifier, "", "", 0); // use the SASHELP.VMEMBER view to get names of all of the catalogs in the specified library string selectclause = "select memname from sashelp.vmember where libname='" + tn.Text + "' and memtype in ('CATALOG')"; adorecordset.Open( selectclause, adoconnect, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, (int) ADODB.CommandTypeEnum.adCmdText); while (!adorecordset.EOF) { TreeNode cat = tn.Nodes.Add(adorecordset.Fields["memname"].Value.ToString()); cat.ImageIndex = (int)CatImages.Catalog; cat.SelectedImageIndex = (int)CatImages.Catalog; cat.Tag = "CATALOG"; adorecordset.MoveNext(); } } catch {} finally { adoconnect.Close(); } } } tvLibsCats.EndUpdate(); Cursor.Current = c; UpdateToolbar(); }
private dbdefinitionEntity GenerateEntity(ADOX.Table ptbl, ADODB.Connection pcon) { dbdefinitionEntity entity = new dbdefinitionEntity(); entity.name = ptbl.Name; entity.description = GetTableDescription(ptbl, pcon); // Generate attributes ArrayList alAttributes = new ArrayList(); int intColIndex = 0; ADODB.Recordset rs = new ADODB.RecordsetClass(); rs.Open("SELECT * FROM [" + ptbl.Name + "] WHERE (3=4)", pcon, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, 0); foreach (ADODB.Field fld in rs.Fields) { alAttributes.Add(GenerateColumn(ptbl.Columns[fld.Name], intColIndex)); intColIndex++; } rs.Close(); if (alAttributes.Count != 0) { entity.attributes = (dbdefinitionEntityAttribute[])alAttributes.ToArray(typeof(dbdefinitionEntityAttribute)); } // Generate primary/unique keys/constraints entity.keys = new dbdefinitionEntityKeys(); ArrayList alUniqueKeys = new ArrayList(); ArrayList alForeignKeys = new ArrayList(); int intIndex = 0; foreach (ADOX.Key key in ptbl.Keys) { switch (key.Type) { case ADOX.KeyTypeEnum.adKeyPrimary: entity.keys.primarykey = new dbdefinitionEntityKeysPrimarykey(); entity.keys.primarykey.name = ptbl.Name + "_pk"; // get all primary key columns ArrayList aAttr = new ArrayList(); foreach (ADOX.Column col in key.Columns) { dbdefinitionEntityKeysPrimarykeyAttributeref attr = new dbdefinitionEntityKeysPrimarykeyAttributeref(); attr.attribute = col.Name; aAttr.Add(attr); } // create the primary key attribute array entity.keys.primarykey.attributeref = (dbdefinitionEntityKeysPrimarykeyAttributeref []) aAttr.ToArray(typeof(dbdefinitionEntityKeysPrimarykeyAttributeref)); break; case ADOX.KeyTypeEnum.adKeyUnique: dbdefinitionEntityKeysUniquekey uniquekey = new dbdefinitionEntityKeysUniquekey(); ArrayList alAttributeRefs = new ArrayList(); foreach (ADOX.Column col in key.Columns) { dbdefinitionEntityKeysUniquekeyAttributeref attributeref = new dbdefinitionEntityKeysUniquekeyAttributeref(); attributeref.attribute = col.Name; alAttributeRefs.Add(attributeref); } if (alAttributeRefs.Count != 0) { uniquekey.attributeref = (dbdefinitionEntityKeysUniquekeyAttributeref[])alAttributeRefs.ToArray(typeof(dbdefinitionEntityKeysUniquekeyAttributeref)); } // check for duplicate indexes - ignore duplicate index defintions bool isDuplicate = false; foreach (dbdefinitionEntityKeysUniquekey existingKey in alUniqueKeys) { if (uniquekey.attributeref.Length == existingKey.attributeref.Length) { isDuplicate = true; for (int i = 0; i < uniquekey.attributeref.Length; i++) { if (!uniquekey.attributeref[i].attribute.Equals(existingKey.attributeref[i].attribute)) { isDuplicate = false; break; } } if (isDuplicate) { break; } } } if (!isDuplicate) { uniquekey.name = ptbl.Name + "_uk" + intIndex; alUniqueKeys.Add(uniquekey); } break; case ADOX.KeyTypeEnum.adKeyForeign: dbdefinitionEntityKeysForeignkey foreignkey = new dbdefinitionEntityKeysForeignkey(); foreignkey.name = ptbl.Name + "_fk" + intIndex; foreignkey.foreignentity = key.RelatedTable; foreignkey.cascadingdelete = (key.DeleteRule & ADOX.RuleEnum.adRICascade) != 0; foreignkey.attributeref = new dbdefinitionEntityKeysForeignkeyAttributeref(); foreignkey.attributeref.attribute = key.Columns[0].Name; foreignkey.attributeref.foreignattribute = key.Columns[0].RelatedColumn; alForeignKeys.Add(foreignkey); break; } intIndex++; } if (alUniqueKeys.Count != 0) { entity.keys.uniquekey = (dbdefinitionEntityKeysUniquekey[])alUniqueKeys.ToArray(typeof(dbdefinitionEntityKeysUniquekey)); } if (alForeignKeys.Count != 0) { entity.keys.foreignkey = (dbdefinitionEntityKeysForeignkey[])alForeignKeys.ToArray(typeof(dbdefinitionEntityKeysForeignkey)); } // Generate indices ArrayList alIndexes = new ArrayList(); intIndex = 0; foreach (ADOX.Index idx in ptbl.Indexes) { if (!idx.PrimaryKey) { dbdefinitionEntityIndex index = new dbdefinitionEntityIndex(); index.unique = idx.Unique; index.ignorenulls = (idx.IndexNulls == ADOX.AllowNullsEnum.adIndexNullsIgnore); ArrayList alAttributeRefs = new ArrayList(); foreach (ADOX.Column col in idx.Columns) { dbdefinitionEntityIndexAttributeref attributeref = new dbdefinitionEntityIndexAttributeref(); attributeref.attribute = col.Name; alAttributeRefs.Add(attributeref); } index.attributeref = (dbdefinitionEntityIndexAttributeref[])alAttributeRefs.ToArray(typeof(dbdefinitionEntityIndexAttributeref)); // check for duplicate indexes - ignore duplicate index defintions bool isDuplicate = false; foreach (dbdefinitionEntityIndex existingIndex in alIndexes) { if (index.attributeref.Length == existingIndex.attributeref.Length) { isDuplicate = true; for (int i = 0; i < index.attributeref.Length; i++) { if (!index.attributeref[i].attribute.Equals(existingIndex.attributeref[i].attribute)) { isDuplicate = false; break; } } if (isDuplicate) { break; } } } if (!isDuplicate) { index.name = ptbl.Name + "_idx" + intIndex; alIndexes.Add(index); } intIndex++; } } if (alIndexes.Count != 0) { entity.indexes = (dbdefinitionEntityIndex[])alIndexes.ToArray(typeof(dbdefinitionEntityIndex)); } // mark 1:1 relationship foreign keys with "one-to-one" attribute if (entity.keys != null && entity.keys.foreignkey != null && entity.indexes != null) { foreach (dbdefinitionEntityKeysForeignkey foreignkey in entity.keys.foreignkey) { foreach (dbdefinitionEntityIndex index in entity.indexes) { if (index.attributeref.Length == 1 && index.attributeref[0].attribute.Equals(foreignkey.attributeref.foreignattribute)) { if (index.unique) { foreignkey.onetoone = true; } } } } } // Generate hashcode of entity definition XmlSerializer entityDefSerializer = new XmlSerializer(typeof(dbdefinitionEntity)); StringWriter stringWriter = new StringWriter(); entityDefSerializer.Serialize(stringWriter, entity); String entityDef = stringWriter.ToString(); entity.hashcode = entityDef.GetHashCode().ToString(); return(entity); }