code_junkie

TableName in Linq

Nov 13th, 2011
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. Dim TableName As String ="City"
  2. Dim Str As String="Select * from "+TableName+""
  3.  
  4. PropertyInfo info = dataContext.GetType().GetProperty( "City" );
  5. IQueryable table = info.GetValue( dataContext, null ) as IQueryable;
  6.  
  7. var query = table.Where( t => t.Column == "Value" )
  8. .Select( t => t.OtherColumn );
  9.  
  10. string linqObjectName = "Test";
  11. PropertyInfo info = db.GetType().GetProperty(linqObjectName);
  12. IQueryable table = info.GetValue(db, null) as IQueryable;
  13.  
  14.  
  15. PropertyInfo[] properties = table.GetType().GetProperties();
  16.  
  17.  
  18.  
  19. ltr.Text += "properties: <hr size=1/>";
  20. foreach (PropertyInfo p in properties)
  21. {
  22. ltr.Text += p.Name + "<br />";
  23.  
  24. }
  25.  
  26. PropertyInfo[] properties =
  27. table.Where("WebRef = "" + webref + """).ElementType.GetProperties();
Add Comment
Please, Sign In to add comment