Guest User

Untitled

a guest
Feb 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. string column = "AnyColumn"; // This is column name (It is dynamic and has boolean value)
  2.  
  3. //Calling the function and passing arguments
  4. ProcessingLayer.CheckClientsFeature(999, column);
  5.  
  6. <------------------- This code can be in processing layer --------------------------->
  7.  
  8. public object GetPropValue(object obj, string propName)
  9. {
  10. return obj.GetType().GetProperty(propName).GetValue(obj, null);
  11. }
  12. public bool CheckClientsFeature(int clientcode, string clientfeature)
  13. {
  14. var featureBoolVal = db.Clients.Where(x => x.ClientCode == clientcode).ToList().Select(x => GetPropValue(x, clientfeature)).FirstOrDefault();
  15. if(featureBoolVal.Equals(true))
  16. {
  17. return true;
  18. }
  19. return false;
  20. }
  21. <------------------------------------------------------------------------------------->
Add Comment
Please, Sign In to add comment