public static List<string> GetClientEntityProperties(EFDataSource eds, Assembly assembly) { List<string> lst = new List<string>(); if (eds != null && !string.IsNullOrEmpty(eds.RemoteName) && eds.RemoteName.IndexOf('.') != -1) { List<string> entityClasses = eds.GetEntityClasses(); string assemblyName = eds.RemoteName.Split('.')[0]; foreach (string entity in entityClasses) { foreach (Type type in assembly.GetTypes()) { DataContractAttribute[] attributes = type.GetCustomAttributes(typeof(DataContractAttribute), false) as DataContractAttribute[]; if (attributes.Length == 1 && attributes[0].Name == entity) { string ns = attributes[0].Namespace; if (!string.IsNullOrEmpty(ns)) { ns = ns.Substring(ns.LastIndexOf('/') + 1); if (string.Compare(ns, assemblyName, true) == 0) { lst.Add(type.Name); break; } } } } } } return lst; }
private static object CreateEFDataSource() { #region #CreateEFDataSource EFDataSource ds = new EFDataSource(new EFConnectionParameters()); ds.Name = "Contacts"; ds.ConnectionParameters.CustomAssemblyPath = Application.StartupPath + @"\EFDataModel.dll"; ds.ConnectionParameters.CustomContextName = "EFDataModel.ContactsEntities"; ds.ConnectionParameters.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\Contacts.mdf;integrated security=True;"; #endregion #CreateEFDataSource return(ds); }
private void Form1_Load(object sender, EventArgs e) { EFDataSource ds = new EFDataSource(new EFConnectionParameters()); ds.Name = "Contacts"; ds.ConnectionParameters.CustomAssemblyPath = Application.StartupPath + @"\EFDataModel.dll"; ds.ConnectionParameters.CustomContextName = "EFDataModel.ContactsEntities"; ds.ConnectionParameters.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\Contacts.mdf;integrated security=True;"; this.spreadsheetControl1.Document.MailMergeDataSource = ds; this.spreadsheetControl1.Document.MailMergeDataMember = "Customers"; this.spreadsheetControl1.Document.Worksheets[0].Cells["A1"].Formula = "=FIELD(\"Company\")"; try { IList <IWorkbook> resultWorkbooks = spreadsheetControl1.Document.GenerateMailMergeDocuments(); string filename = "SavedDocument0.xlsx"; resultWorkbooks[0].SaveDocument(filename, DocumentFormat.OpenXml); System.Diagnostics.Process.Start(filename); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception"); } }
public static List<string> GetClientEntityProperties(EFDataSource eds, Assembly assembly) { return InvokeMethod("GetClientEntityProperties", new object[] { eds, assembly }) as List<string>; }
public Test() { DataSource = InitializeEFDataSource(); }