The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Field not found in data source

Last post 22 hours, 49 minutes ago by dmoring. 12 replies.
Sort Posts: Previous Next
  •  08-26-2008, 9:40 AM 10923

    Field not found in data source

    Hello,

    I am just getting my feet wet in EntitySpaces.  I am trying to bind a join query to a asp.net gridview and keep getting the message "field not found".  I know that it has something to do with having the same field name "description" in the joined tables.  I can bind other fields in the joins but when I included the two "description" fields from two joined tables I get the message "Field not found in data source".  I have tried alias and combination of things from the forum but not able to come up with anything.

     I am using SQL2005 and Visual Studio 2008.

     This is this exact error message that is returned per my code snippet below.

     "A field or property with the name 'Description1' was not found on the selected data source."

     

    GoalQuery qGoal = new GoalQuery("g");

    InterventionTypeQuery qIntType = new InterventionTypeQuery("it");

    GoalAreaQuery qGoalArea = new GoalAreaQuery("ga");

    UserQuery qUser = new UserQuery("u");

    qGoal.Select

    (

    qGoal.Description.Coalesce("g.Description"),

    qIntType.Description.Coalesce("it.Description")

     

    );

    qGoal.InnerJoin(qIntType).On (qIntType.InterventionTypeID==qGoal.InterventionTypeID);

    qGoal.InnerJoin(qGoalArea).On(qGoalArea.GoalAreaID == qGoal.GoalAreaID);

    qGoal.InnerJoin(qUser).On(qUser.UserID == qGoal.CreatedByUserID);

    GoalCollection Coll = new GoalCollection();

    Coll.Load(qGoal);

     

     I get the same error results when removing the Coalesce statements

    qGoal.Select

    (

    qGoal.Description,

    qIntType.Description

     

    );

     

  •  08-26-2008, 9:45 AM 10927 in reply to 10923

    Re: Field not found in data source

    Try this on one of them:

    qIntType.Description.Coalesce("it.Description").As("MyDescription");

    Let us know if this works ...


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  08-26-2008, 12:34 PM 10934 in reply to 10927

    Re: Field not found in data source

    I still get:

    A field or property with the name 'MyDescription' was not found on the selected data source.

  •  08-26-2008, 12:50 PM 10935 in reply to 10934

    Re: Field not found in data source

    Darrinb:

    I still get:

    A field or property with the name 'MyDescription' was not found on the selected data source.

    Can you provide the create statements for those tables and the sql for that query?

    Does that query run from SQL Management Studio? I had this problem before when I forgot to update a query after editing a table.


    Current Projects:
    iVirtualDocket | iWontRemember
  •  08-26-2008, 12:56 PM 10936 in reply to 10935

    Re: Field not found in data source

    While debugging in Visual Studio when you drill down into your collections datatable in a quick watch window do you see a column named 'MyDescription'? If you do try binding like so to your gridview

     

    Code:
    MyGridView.DataSource = myCollection.LowLevelBind();
     
    Regards,

    Scott Schecter
    EntitySpaces | My Site
  •  08-26-2008, 12:56 PM 10937 in reply to 10935

    Re: Field not found in data source

    Also, after the query check your Query.es.LastQuery and you will see what columns it is bringing back, the rest should be to simply look at your bindings.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  08-26-2008, 1:00 PM 10938 in reply to 10937

    Re: Field not found in data source

    Here is the problem. Your first issue was that it couldn't find Description1. You would have gotten this same error if you had used ADO.NET, remember, when you use SQL to calulate a column whether it be from AVG or COALESCE it will not use your regular column name. Thus you have to provide an alias, this is done via the As() statement in ES. Now your problem is your bindings, please just set your grid to auto-generate and it will work, then re-add bindings (specifically) if you need to.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  08-26-2008, 1:08 PM 10939 in reply to 10936

    Re: Field not found in data source

    The lowlevelbind did the trick!  What exactly does/is lowlevelbind do? 

     

    Thanks Scott!

  •  08-26-2008, 1:44 PM 10941 in reply to 10939

    Re: Field not found in data source

    It is used to bind directly to the underlying ADO.NET DataView.

    Regards,

    Scott Schecter
    EntitySpaces | My Site
  •  08-26-2008, 3:35 PM 10946 in reply to 10941

    Re: Field not found in data source

    There is a special DLL in the Runtime folder for Web binding that should make LowLevelBind() unnecessary. You will see it if you look in the Runtime area. LowLevelBind does not call your property settors, try the Special DLL and let us know if it works, I would really like to know, just use the "Web" version and bind directly to the collection and let us know if it works.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  08-27-2008, 6:10 AM 10961 in reply to 10946

    Re: Field not found in data source

    Mike,

    I removed the LowLevelBind, removed the existing reference to "EntitySpaces.Core.dll" and made a reference to the "EntitySpaces.Core.Dll" under the Web folder.  The results.....my binding worked just fine.  Thanks!

     

     

  •  23 hours, 0 minutes ago 12729 in reply to 10941

    Re: Field not found in data source

    Scott.Schecter:
    It is used to bind directly to the underlying ADO.NET DataView.

    I am using an old ES (v1.5.3!) to bind to a ASP.NET dataview with some derived (i.e., col1 + col2) fields and get the same error: A field or property with the name 'x' was not found on the selected data source.  The field is there in the view and I can return the field on one of the collection items, so I will guess that this is the same issue.  My questions are:

    1) Is there a way to "mimic" the low-level binding behavior discussed in this thread?  Provide a reference to the underlying datatable in the custom entity class and bind to that?
    2) Off-Topic-but-not-really since I know it is the "easy" answer to this post - upgrade!: So... can I run ES v1.5.3 alongside the latest ES (but obviously in different projects/apps)?  How about myGen - the same issue here: can I run v1.2.0.7 to compile the ES v1.5.3 classes?  I've got many apps using ES v1.5.3 and I don't have the time to go back and update them all and fix syntax for newer versions so I want to be able to compile either way.

    Thanks

    D-

  •  22 hours, 49 minutes ago 12730 in reply to 12729

    Re: Field not found in data source

    Man, I'm not being real smart this am - a space in the datagrid bind column def caused it... sorry, but I still have the question below on upgrading....

    dmoring:
    Off-Topic-but-not-really since I know it is the "easy" answer to this post - upgrade!: So... can I run ES v1.5.3 alongside the latest ES (but obviously in different projects/apps)?  How about myGen - the same issue here: can I run v1.2.0.7 to compile the ES v1.5.3 classes?  I've got many apps using ES v1.5.3 and I don't have the time to go back and update them all and fix syntax for newer versions so I want to be able to compile either way.

    Thanks

    D-

View as RSS news feed in XML