Coder Social home page Coder Social logo

Comments (4)

okedoki avatar okedoki commented on August 25, 2024

Two issues what I have at this moment:

  1. I didn't find a way to use create a command to work with several rows for CRUD.
    For example, I expect to select records with ID =1,2,3. How can I do it?
    Now, I have to do it in the loop.
foreach (CRUDInfo retriveInfo in rInfoList)
                        {
                            q.Condition = ((QField)retriveInfo.IdPair.Key == new QConst(retriveInfo.IdPair.Value));
                            selectComand = dbContext.CommandBuilder.GetSelectCommand(q);
                            dbContext.InitCommand(selectComand);

                            using (var rdr = selectComand.ExecuteReader())
                            {
                                while (rdr.Read())
                                {
                                    retrievedList.Add(new CRUDInfo()
                                    {
                                        TableName = retriveInfo.TableName,
                                        ObjectDictionary = Enumerable.Range(0, rdr.FieldCount).ToDictionary(rdr.GetName, rdr.GetValue)
                                    });

  }
                            }
                        } 
  1. If use update or create, I can't use IDictionary only Dictionary. Can it be modified?
    CRUDInfo.ObjectDictionary is an IDictionary<string, object>,but I can't pass it directly to GetUpdateCommand, only through the wrapper.
var changeset = new Dictionary<string, object>(CRUDInfo.ObjectDictionary);
 updateCommand = dbContext.CommandBuilder.GetUpdateCommand(q, changeset) 

from data.

VitaliyMF avatar VitaliyMF commented on August 25, 2024

@okedoki regarding CRUDInfo, it seems you're trying to implement the concept that looks similar to old ADO.NET DataTable/DataRow - could you check issue #2 (RecordSet implementation)? I've already added first draft of this structure: RecordSet.cs. Conceptually RecordSet works like DataTable and suitable for processing many records at once. Right now I'm working on DbDataAdapter.Select().ToRecordSet() and DbDataAdapter.Update(RecordSet) implementations -- I assume that these enhancements may make your CRUDInfo structure unnecessary.

  1. I didn't find a way to use create a command to work with several rows for CRUD.
    For example, I expect to select records with ID =1,2,3. How can I do it?

why not make one select for selecting several records at once?.. like that:

var recordIds = new int[] { 1, 2, 3}; 
new Query(someTableName, new QConditionNode( (QField)"id", Conditions.In, new QConst(recordIds) ) );
  1. If use update or create, I can't use IDictionary only Dictionary. Can it be modified?

Oh I see, I forgot to add overload for IDictionary<string,object> in DbCommandBuilderExtensions. Give me 10 minutes :-)

from data.

VitaliyMF avatar VitaliyMF commented on August 25, 2024

@okedoki take a look to the updated SqliteDemo.DataAdapter -- I've added sample code for dictionary-driven CRUD operations, and new RecordSet.

Also all DbCommandGenerator / DbDataAdapter methods support IDictionary<string,object>. I've just published 1.0.0-alpha4 and you can try it.

from data.

VitaliyMF avatar VitaliyMF commented on August 25, 2024

It seems this question is no longer actual for latest 1.0-final release.

from data.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.