Created
February 26, 2014 14:33
-
-
Save alexsandro-xpt/9230438 to your computer and use it in GitHub Desktop.
Mapping database to entity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override IQueryable<TEntity> GetAll() | |
{ | |
var table = base.Context.ExecutarSQL(Querys[QueryType.GetAll], null); | |
var i = table.Rows.Cast<object>().Select(row => | |
{ | |
var entity = new TEntity(); | |
foreach (var prop in entity.GetType().GetProperties()) | |
{ | |
var property = entity.GetType().GetProperty(prop.Name, BindingFlags.Public | BindingFlags.Instance); | |
if (null != property && property.CanWrite) | |
{ | |
property.SetValue(entity, ((DataRow)row)[prop.Name], null); | |
} | |
} | |
return entity; | |
}); | |
return i.AsQueryable(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment