Question about using class property in rowschema

May 25, 2013 at 6:59 PM
I'm trying to solve this problem that occurred to me while I was starting to develop an application with this db.

I have this class:
public class ItemPlant
{

    public ItemPlant()
    {
        ID=Guid.NewGuid();
    }

    public Guid ID{get;set;}
    public string ModelType { get; set; }
    public Plant _plant { get; set; }
  .......

}

public class Plant
{

    public Plant()
    {
        ID = Guid.NewGuid();
    }

    public Guid ID { get; set; }
    public string Description { get; set; }


}
and in rowschema i would do a things like:

[RegisterView]
public class ItemPlantView:View<ItemPlant>
{
    public class RowSchema:RDBSchema
    {
        public string ModelType;


    public string ModelType { get; set; }
    public Plant _plant { get; set; }
      ...... 

    }

    public ItemPlantView()
    {
        this.Name = "Item plant";
        this.Description = "Primary view for ItemPlan";
        this.isPrimaryList = true;
        this.isActive = true;
        this.BackgroundIndexing = true;
        this.Version = 2;

        this.Schema = typeof(ItemPlantView.RowSchema);
        this.AddFireOnTypes(typeof(ItemPlant));

        this.Mapper = (api, docid, doc) => {

            api.EmitObject(docid, doc);
        };
    }

}

but i receive an error when raptor attemp to register view.

Probably this is not the correct way.

therefore , how can I use this class in the rowschema of view?
I need, when i recover the ItemPlant class, the associated plant class.

Thank's in advance and sorry for my english!
Coordinator
May 26, 2013 at 12:19 PM
What is the error you are getting?
May 26, 2013 at 12:28 PM
I have a GenericArguments exception during registering view, probably because i add this line in rowschema
 public Plant _plant { get; set; }
But I realized that I was using my views in the wrong way.

I wanted to directly retrieve the object from the query, as you do with mongodb.

Instead, I realized that I have, after the query, fetch the object.

However, overcome this problem, now I am experiencing some issues with deletions. It seems that not always the objects are deleted from the store. it is possible that I am doing something wrong?

To delete call the "Delete" command and nothing else.

But if I close and reopen the application I happen to find the same elements that I had previously deleted.
Coordinator
May 26, 2013 at 12:44 PM
Yep, the row schema's cannot be objects you can only use int,string,... data types.

Add the properties you need from the Plant object to your schema and use Emit(...) instead of EmitObject(...)
May 26, 2013 at 12:57 PM
MGholam wrote:
Yep, the row schema's cannot be objects you can only use int,string,... data types.

Add the properties you need from the Plant object to your schema and use Emit(...) instead of EmitObject(...)
Yes, i use Emit now and work perfectly!
May 26, 2013 at 6:05 PM
..... sorry but continually I have the problem of deletions: delete an item, and after a while 'time find all deleted items, as if suddenly had a rollback total!
Is there some bug or i have some problem of configuration??

I like very much this DB.... any help to make work will be much appreciated!
Coordinator
May 26, 2013 at 6:48 PM
Deletes are marked as deleted in the storage file and views.

Make sure you shutdown properly.

Other than the above you should post the code you are using for me to help you.
May 26, 2013 at 7:04 PM
OK, probably was my mistake: at the beginning i had ignored the shutdown command! Now i have deleted my store and restarted by zero!

I making some test and i don't have problem for now.

But, I have another question (sorry, but i would start to use this DB at the best!):

I have three simple object:
 public class ItemPlant
    {

        public ItemPlant()
        {
            ID=Guid.NewGuid();
        }

        public Guid ID{get;set;}
        public string ModelType { get; set; }
        public Plant plantObject { get; set; }
        public string CustomerName { get; set; }
        public string Units { get; set; }
        public string SalesOrder { get; set; }
        public DateTime ContractualDelivery { get; set; }
        public DateTime ActualSlotDate { get; set; }
        public Note noteObject { get; set; }
     
    }

    public class Plant
    {

        public Plant()
        {
            ID = Guid.NewGuid();
        }

        public Guid ID { get; set; }
        public string Description { get; set; }
      

    }

    public class Note
    {

        public Note()
        {
            ID = Guid.NewGuid();

        }

        public Guid ID { get; set; }
        public string Description { get; set; }
        public string Color { get; set; }

    }
and this views:
 [RegisterView]
    public class ItemPlantView:View<ItemPlant>
    {
        public class RowSchema:RDBSchema
        {
            public string ModelType;
            public string plantString;
            [CaseInsensitive]
            public string CustomerName;
            public string Units;
            public string SalesOrder;
            public DateTime ContractualDelivery;
            public DateTime ActualSlotDate;
            public string noteString;
            public string ColorString;
           
            
        }

        public ItemPlantView()
        {
            this.Name = "Item plant";
            this.Description = "Primary view for ItemPlan";
            this.isPrimaryList = true;
            this.isActive = true;
            this.BackgroundIndexing = false;
            this.Version = 11;
           
           

            this.Schema = typeof(ItemPlantView.RowSchema);
            this.AddFireOnTypes(typeof(ItemPlant));

            this.Mapper = (api, docid, doc) => {
                api.Emit(docid, doc.ModelType,doc.plantObject.Description,doc.CustomerName,
                    doc.Units, doc.SalesOrder, doc.ContractualDelivery, doc.ActualSlotDate, doc.noteObject.Description, doc.noteObject.Color);
            };
        }

    }

   

    [RegisterView]
    public class PlantView : View<Plant>
    {
        public class RowSchema : RDBSchema
        {
            [CaseInsensitive]
            public string Description;
           
        }

        public PlantView()
        {
            this.Name = "Plant";
            this.Description = "Primary view for Plant";
            this.isPrimaryList = true;
            this.isActive = true;
            this.BackgroundIndexing = false;
            this.Version = 11;

            this.Schema = typeof(PlantView.RowSchema);
            this.AddFireOnTypes(typeof(Plant));
            
            //this.AddFireOnTypes(typeof(ItemPlant));

            this.Mapper = (api, docid, doc) =>
            {
                api.EmitObject(docid, doc);
            };
        }

    }


    [RegisterView]
    public class NoteView : View<Note>
    {
        public class RowSchema : RDBSchema
        {
            [CaseInsensitive]
            public string Description;
            public string Color;

        }

        public NoteView()
        {
            this.Name = "Note";
            this.Description = "Primary view for Note";
            this.isPrimaryList = true;
            this.isActive = true;
            this.BackgroundIndexing = false;
            this.Version = 11;

            this.Schema = typeof(NoteView.RowSchema);
           this.AddFireOnTypes(typeof(Note));
           // this.AddFireOnTypes(typeof(ItemPlant));

            this.Mapper = (api, docid, doc) =>
            {
                api.EmitObject(docid, doc);
            };
        }

    }
Now, if i would change the properties "color" for one object Note, when I save, I have the correct data for that object, but i don't have the change reflected in ItemPlan object. If I get the result querying the view ItemPlanView i have the old value for color.

Where am I doing wrong???