Here are the examples of the csharp api class System.Data.Common.DbDataReader.GetColumnOrdinal(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Example
0
1. Example
View licensepublic static T ToEntity<T>(this DbDataReader reader) { T entity = (T)Activator.CreateInstance(typeof(T)); List<string> properties = LibraryHelper.GetProperties(typeof(T)); foreach (string property in properties) { int ordinal = reader.GetColumnOrdinal(property); if (ordinal >= 0) { object value = reader.GetValue(ordinal); if (!(value is DBNull)) { LibraryHelper.SetPropertyValue(entity, property, value); } } } return entity; }