Although it is a congestion model, although it is a strong type, xcode also supports traversing any database structure and reading data in a strong type (compared to dictionary access such as dataset) mode.
It is easy to traverse the database structure, and most ORM supports it.
However, it is a little complicated to read data in a strongly typed manner without entity classes. The principle of xcode is to dynamically create an entity class inherited from entity <> for each table, and then operate the entity class through the interface.
CodeThere is a fast reflection, although there is no performance loss, but it is quite awkward to use. Here it shows that xcode does not support dynamic access to entity-class metadata.
// Add a connection Dal . Addconnstr ( "Test" , "Provider = Microsoft. Jet. oledb.4.0 ;" + "Data source=test.xls ;" + "Extended properties = Excel 8.0 ;" , Null , Null ); Dal Dal = Dal . Create ( "Test" ); // Traverse all tables Foreach ( Xtable Table In Dal. Tables ){ Console . Writeline ( "Table {0 }:" , Table. Name ); // Create an entity operator. An entity class is dynamically generated for the data table and compiled using codedom. Ientityoperate OP = Dal. createoperate (table. Name. Replace ( "$" ,Null )); // Because of the dynamic code generation defect, $ in the table name has been removed, and the Excel query must always add brackets to the table name, or is there $ // below to set meta through quick reflection. tablename Type Type = op. GetType (); type = Typeof ( Entity <>. Meta ). Makegenerictype (type ); Propertyinfox . Create (type, "Tablename" ). Setvalue ( "[" + Table. Name + "]" ); // Skip if no record exists If (Op. findcount () <1) Continue ; // Output Header Foreach ( Fielditem Item In Op. Fields ){ If (Item. Name. startswith ( "F" )) Break ; Console . Write ( "{0} \ t" , Item. Name );} Console . Writeline ();// Search for all data Entitylist < Ientity > List = op. findall (); // Dataset DS = List. todataset (); // output data Foreach ( Ientity Entity In List ){ Foreach ( Fielditem Item In Op. Fields ){ If (Item. Name. startswith ( "F" ))Break ; Console . Write ( "{0} \ t" , Entity [item. Name]);} Console . Writeline ();}}