Enhancement to GetObjectByID

4 posts, 0 answers
  1. Alfred Ortega
    Alfred Ortega avatar
    193 posts
    Member since:
    May 2005

    Posted 06 Oct 2009 Link to this post

    Add a new method to the scope class with the following signature:

    public T GetObjectByID<T>(string objectID){}

    I think it's easier and more intuitive than the current method.

    Al
  2. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 08 Oct 2009 Link to this post

    Hello Alfred Ortega,

    We will take a look at the Telerik OpenAccess API in order to find out where generic methods are missing. We will do our best to add the missing items in the future.
    We appreciate your proposal.

    Kind regards,
    Damyan Bogoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Alfred Ortega
    Alfred Ortega avatar
    193 posts
    Member since:
    May 2005

    Posted 08 Oct 2009 Link to this post

    That is great news - thank you.

    Do you know when (or if) the following will be supported?

     
     
    var results = from items in objectScope.Extent<Foo>()  
                  where items.Discontinued == true 
                  select items;  
     
    objectScope.RemoveAll(results); 

    As shown in Scott Guthries blog (http://weblogs.asp.net/scottgu/archive/2007/07/11/linq-to-sql-part-4-updating-our-database.aspx)

    Al
  5. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 09 Oct 2009 Link to this post

    Hello Alfred Ortega,

    In fact, the query that you provided is supported. You should use the IObjectScope Remove method. It can accept as parameter IEnumerable or IEnumerator variables as well as single persistent capable instances:

    var results = from items in scope.Extent<Product>()
                  where items.Discontinued == true
                  select items;
    scope.Transaction.Begin();
    scope.Remove(results);
    scope.Transaction.Commit();

    If  the table, from which you are deleting records with the preceding query, is a parent table you can use cascading delete as well.
    Additional information about the cascading delete option can be found in the following Knowledge Base article - CRUD example with Telerik OpenAccess ORM. There is also a demo project in the Code Library - Implementing cascading delete with Telerik OpenAccess ORM.
    I hope you will find this information helpful. If you have any other questions, please do not hesitate to contact us.

    Regards,
    Damyan Bogoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top