TableProvider.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // TableProvider.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. // Marek Habersack <[email protected]>
  7. //
  8. // Copyright (C) 2008-2009 Novell Inc. http://novell.com
  9. //
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. //
  30. using System;
  31. using System.Collections.Generic;
  32. using System.Collections.ObjectModel;
  33. using System.ComponentModel;
  34. using System.Linq;
  35. using System.Security.Permissions;
  36. using System.Web.UI;
  37. namespace System.Web.DynamicData.ModelProviders
  38. {
  39. [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  40. [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  41. public abstract class TableProvider
  42. {
  43. protected TableProvider (DataModelProvider model)
  44. {
  45. DataModel = model;
  46. }
  47. public abstract ReadOnlyCollection<ColumnProvider> Columns { get; }
  48. public DataModelProvider DataModel { get; private set; }
  49. public virtual Type EntityType { get; protected set; }
  50. public virtual string Name { get; protected set; }
  51. public virtual object EvaluateForeignKey (object row, string foreignKeyName)
  52. {
  53. return DataBinder.GetPropertyValue (row, foreignKeyName);
  54. }
  55. public abstract IQueryable GetQuery (object context);
  56. public override string ToString ()
  57. {
  58. string name = Name;
  59. if (String.IsNullOrEmpty (name))
  60. return base.ToString ();
  61. return name;
  62. }
  63. }
  64. }