Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesDal2 insert, update and delate without return valueDal2 insert, update and delate without return value
Previous
 
Next
New Post
4/3/2015 1:55 PM
 

Hallo,

it seems that the default DataContext implementation for the underlying PetaPoco library, differs in that insert, update and delete functions, return no value is this right?

In PetaPoco, the insert returns the primary key of the inserted record, and the update and delete return the number or rows updated/deleted.

Is there something I'm missing with the DataContext.GetIstance() and then the .GetRepository(of..) so that I have those CRUD operations returning value or should I implement directly the PetaPoco library for that functionality?

Thanks

 
New Post
4/4/2015 11:35 AM
 
that's deliberate, you can see the insert/update/delete methods return void (http://www.dnnsoftware.com/community-...) - for update and delete it saves running a perhaps unnecessary query (you can always use the dal2 executescalar to do a count(*) of the table if you need the count). For insert's it's unnecessary as after inserting an object, it's id is populated, providing you have a primarykey defined) - http://www.dnnsoftware.com/answers/ho... is a good example of this

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
4/4/2015 3:39 PM
 

Thank you for your kind answer as always. Good to know about the insert, that's a good thing!

About Delete and Update it could have been useful to know if those command actually had some effect and I don't think those triggered additional selects in PetaPoco. I inspected PetaPoco sources, and the count of affected lines seems to be just a default return value of the ExecuteNonQuery() function.

Using DNN DataContext if you want to check if the commands had some effect, you have to issue 2 count(*) both before and after the commands.
 
New Post
4/5/2015 6:13 PM
 
feel free to log this as a bug (or you could submit this as a pull request - http://www.dnnsoftware.com/wiki/page/... ), but the primary issue would be that it would require a change in the method signatures which would break binary compatibility, which is not something we would want.

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
4/5/2015 6:27 PM
 
Hallo Cathal, I think the real "Important" thing is retrieving the auto primary key after insert and it seems that the default DataContext already does this as you explained.
About the update and delete, I don't think it's so important to jutify a breaking change. Since I'm totally new to module developement (but I used PetaPoco on my own before) I just wanted to be sure I wasn't missing something. Thanks again for your kind support!
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesDal2 insert, update and delate without return valueDal2 insert, update and delate without return value


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out