Update All

4 posts, 0 answers
  1. David
    David  avatar
    66 posts
    Member since:
    Aug 2010

    Posted 07 Apr 2014 Link to this post

    Hi,

    I'm trying to use the new Bulk Update in Data Access version 2014.1.225.2 I cant seem to get this to work.

    I get:

    Error   1   'System.Linq.IQueryable<AnonymousType#1>' does not contain a definition for 'Set' and no extension method 'Set' accepting a first argument of type 'System.Linq.IQueryable<AnonymousType#1>' could be found (are you missing a using directive or an assembly reference?)

    I cant seem to find the correct using / dll to get this to work.

    Thanks

    David. 
  2. Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 09 Apr 2014 Link to this post

    Hi David,

    The extension methods needed for performing Bulk Update are located in the Telerik.OpenAccess namespace. Your project also needs to have a reference to the Telerik.OpenAccess.35.Extensions assembly. However the lack of the respective using statement for the namespace or assembly reference would generally result in a different error.

    Based on the provided error description it appears that the Set method may be called with incorrect argument. We would need some additional information to investigate the situation further. Could you please provide us with the code you are using for the bulk update operation and the structure of the persistent type(s) you attempt to update?

    We are looking forward to your feedback.

    Regards,
    Kristian Nikolov
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
  4. David
    David  avatar
    66 posts
    Member since:
    Aug 2010

    Posted 17 Apr 2014 in reply to Kristian Nikolov Link to this post

    Hi,

    Thanks for that I can now run the UpdateAll Process.

    Is it possible to use this to join two tables and update one of them based on the result of an equation?

    for example

    I have a header table and a details table I want to update the detail table with the percent for each line

    var query = _DbAccess.Tables_Subforms.Join(_DbAccess.Table_MainForm,
                    i => new { i.DB, i.T, i.G },
                    x => new { x.DB, x.T, x.G },
                    (i, x) => new { TDetail = i, TTotal = x.SumofAmount });

                query.UpdateAll(u => u.Set(c => c.TDetail.PercentageSplit,
                    c => (c.TDetail.Weight * c.TDetail.Measure) / c.TTotal));
     
    Thanks
  5. Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 22 Apr 2014 Link to this post

    Hi David ,

    You can update properties with computed values via the UpdateAll method. However, there are certain limitations for the source query - it should not contain projection, grouping, paging or expression involving client side processing. Therefore a source query which involves a Join is not supported by the method.

    Depending on your scenario, an alternative approach to achieve similar functionality could be to have an association between the persistent classes (Tables_Subforms and Table_MainForm as per the example) and use a navigation property in order to update with a value computed using properties from both classes via the UpdateAll method.

    I hope this helps. Do not hesitate to get back to us in case you have additional questions or need help.

    Regards,
    Kristian Nikolov
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
Back to Top