This is a migrated thread and some comments may be shown as answers.

Update All

3 Answers 69 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 2
David asked on 07 Apr 2014, 12:40 PM
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. 

3 Answers, 1 is accepted

Sort by
0
Kristian Nikolov
Telerik team
answered on 09 Apr 2014, 12:28 PM
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.
 
0
David
Top achievements
Rank 2
answered on 17 Apr 2014, 01:40 PM
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
0
Kristian Nikolov
Telerik team
answered on 22 Apr 2014, 12:00 PM
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.
 
Tags
Getting Started
Asked by
David
Top achievements
Rank 2
Answers by
Kristian Nikolov
Telerik team
David
Top achievements
Rank 2
Share this question
or