hey, does editor know to work with inheritance table?

hey, does editor know to work with inheritance table?

eyal_hbeyal_hb Posts: 23Questions: 7Answers: 0

hey, does editor know to work with inheritance tables?

This question has accepted answers - jump to:

Answers

  • eyal_hbeyal_hb Posts: 23Questions: 7Answers: 0

    another question that connect to this subject.
    i have service Table, in my service table i have identity int value and service-type value as primary Keys, know i have another 6 table that connected to this service table with foreign key to the (identity and service-type)!
    now i want to add a new service but not from the parent table,but from 1 of the 6 other table, how can i achieve this with editor?

  • allanallan Posts: 50,303Questions: 1Answers: 7,478 Site admin
    Answer ✓

    hey, does editor know to work with inheritance tables?

    Do you mean something like this? If not, could you clarify what you are looking for please?

    now i want to add a new service but not from the parent table,but from 1 of the 6 other table, how can i achieve this with editor?

    You'd need to have a second DataTable / Editor for the services. Currently Editor doesn't provide the ability to edit nested down tables in the UI. That is something we plan to introduce in future.

    Allan

  • eyal_hbeyal_hb Posts: 23Questions: 7Answers: 0

    hey allan, i understand
    i have a problem with the Mjoin, i have two tables , trip and day trip
    they have many to many connection, form the trip table its ok it load all the data as expected, but from the dayTrip Table its show me an error
    "DataTables warning: table id=example - Incorrect syntax near the keyword 'JOIN'."

    why it happend, all i want to do, is to know if my dayTrip connected to trip so i will be enable/disable to remove the dayTrip row

  • allanallan Posts: 50,303Questions: 1Answers: 7,478 Site admin

    If you add ->debug(true) before the ->process(...) call on the server-side, the JSON returned from the server will show the SQL it is attempting to execute. Can you show me that JSON please?

    Allan

  • eyal_hbeyal_hb Posts: 23Questions: 7Answers: 0

    this the sql-->

    Query: "SELECT DISTINCT  [DayTrip].[DayTrip_Id] as 'dteditor_pkey', [Trip].[Trip_Id] as 'Trip_Id', [Trip].[Trip_Name] as 'Trip_Name', [Trip].[Trip_DaysNum] as 'Trip_DaysNum', [Trip].[Requires_Flights] as 'Requires_Flights' FROM  [DayTrip]  JOIN [Trip_DayTrip] ON [DayTrip].[DayTrip_Id] =    JOIN [Trip] ON [Trip].[Trip_Id] = [Trip_DayTrip].[Trip_Id] WHERE [DayTrip].[DayTrip_Id] IN (@wherein1,@wherein2) "
    
  • allanallan Posts: 50,303Questions: 1Answers: 7,478 Site admin

    This is what it looks like when formatted:

    SELECT DISTINCT
        [DayTrip].[DayTrip_Id] as 'dteditor_pkey',
        [Trip].[Trip_Id] as 'Trip_Id',
        [Trip].[Trip_Name] as 'Trip_Name',
        [Trip].[Trip_DaysNum] as 'Trip_DaysNum',
        [Trip].[Requires_Flights] as 'Requires_Flights'
    FROM  [DayTrip]
    JOIN [Trip_DayTrip] ON [DayTrip].[DayTrip_Id] =    
    JOIN [Trip] ON [Trip].[Trip_Id] = [Trip_DayTrip].[Trip_Id]
    WHERE [DayTrip].[DayTrip_Id] IN (@wherein1,@wherein2)
    

    So yes, line 8 above shows an error since there is no matching condition. Next question is, why is that happening! Can you show me your code that is generating that SQL please?

    Allan

  • eyal_hbeyal_hb Posts: 23Questions: 7Answers: 0

    here the code

    [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
            public ActionResult GetDataDayTrip(Enums.JsonSortType type, int id)
            {
                var settings = Properties.Settings.Default;
                var formData = HttpContext.ApplicationInstance.Context.Request;
                using (var db = new DataTables.Database(settings.DbType, settings.DbConnection))
                {
                    var editor = new Editor(db, "DayTrip", "DayTrip_Id");
                    if (type == PegasusOperation.Common.Classes.Enums.JsonSortType.DayTripByTrip)
                    {
                        editor.Where(q =>
                        q.Where("DayTrip.DayTrip_Id", "(SELECT DayTrip_Id FROM Trip_DayTrip WHERE Trip_Id= " + id + ")", "IN", false)
                        );
                    }
                    editor.Model<Model.DayTripVM>("DayTrip")
                       .Field(new Field("DayTrip.DayTrip_Id")
                        .Validator(Validation.Numeric())
                    )
                     .Field(new Field("DayTrip.DisplayName_Heb")
                        .Validator(Validation.MaxLen(200))
                    )
                     .Field(new Field("DayTrip.DisplayName_Eng")
                        .Validator(Validation.MaxLen(200))
                    )
                     .Field(new Field("DayTrip.HeaderName_Heb")
                        .Validator(Validation.MaxLen(200))
                    )
                    .Field(new Field("DayTrip.HeaderName_Eng")
                        .Validator(Validation.MaxLen(200))
                    )
                    .Field(new Field("DayTrip.TripName")
                        .Validator(Validation.Unique(new ValidationOpts
                        {
                            Message = "שם הטיול קיים, אנא רשמו שם יחודי אחר"
                        }))
                        .Validator(Validation.MaxLen(50))
                    )
                    .Field(new Field("DayTrip.CountryId")
                        .Options(new Options()
                            .Table("Countries")
                            .Value("Country_Id")
                            .Order("Countries.Country_Id")
                            .Label("Country_Name"))
                     .Validator(Validation.Numeric())
                    )
                     .Field(new Field("DayTrip.StartCity")
                        .Validator(Validation.MaxLen(20))
                    )
                     .Field(new Field("DayTrip.FinishCity")
                        .Validator(Validation.MaxLen(20))
                    )
                    .Model<Model.Countries>("Countries")
                    .LeftJoin("Countries", "Countries.Country_Id", "=", "DayTrip.CountryId");
                    //.MJoin(new MJoin("Trip")
                    //.Link("DayTrip.DayTrip_Id", "Trip_DayTrip.DayTrip_Id")
                    //.Link("Trip.Trip_Id", "Trip_DayTrip.Trip_Id")
                    //.Model<Model.Trip>());
                    editor.Debug(true);
                    editor.Process(formData);
                    DtResponse data = editor.Data();
                    return Json(data, JsonRequestBehavior.AllowGet);
                }
            }
    
  • allanallan Posts: 50,303Questions: 1Answers: 7,478 Site admin

    I presume the error happens when the four Mjoin lines are commented back in? Can you show me your Model.Trip model please?

    Allan

  • eyal_hbeyal_hb Posts: 23Questions: 7Answers: 0

    yes, i just comment out this lines because it didn't worked.
    this is my model

     
        public class Trip
        {
            public int Trip_Id { get; set; }
            public string Trip_Name { get; set; }
            public Nullable<int> Trip_DaysNum { get; set; }
            public bool Requires_Flights { get; set; }
        }
    
        public class ToursTrip
        {
            public int Tour_Id { get; set; }
    
        }
    
  • allanallan Posts: 50,303Questions: 1Answers: 7,478 Site admin

    Ah! It's the naming that is tripping my code up. Specifically I have:

    if (partner.Contains(_table + "."))
    

    where _table is the joined table (Trip) and partner is the link table name. Trip_DayTrip. will match Trip..

    Fix committed here. Thanks!

    Allan

  • eyal_hbeyal_hb Posts: 23Questions: 7Answers: 0

    how i can add this fix to my project allan?

  • allanallan Posts: 50,303Questions: 1Answers: 7,478 Site admin
    Answer ✓

    You can either grab the sources from the github repo I linked to above (its a VS project) and build the dlls, or we'll be releasing Editor 1.9.1 probably next week.

    Allan

  • eyal_hbeyal_hb Posts: 23Questions: 7Answers: 0

    Thanks for your help Allan!!

Sign In or Register to comment.