How in the heck to work with Entity Framework??

6 posts, 0 answers
  1. Adam
    Adam avatar
    4 posts
    Member since:
    Mar 2005

    Posted 22 Jul 2012 Link to this post

    Apologies for the slightly aggressive title, but I have been coding, googling, and browsing the forums for hours, and I am basically no nearer to getting anything to work!

    Your advice on working with Entity Framework objects is all over the place, and I can't seem to work out a simple answer.  One page says I should bind to an EntityDataSource, the next says that NeedDataSource is the preferred binding method for Entity Framework.  Oh and for good measure, some people say ObjectDataSource should be used (this is related to the fact I'm using Code First POCOs).  So here are my challenges:

    Binding through EntityDataSource
    If I bind through the entity data source, it works for a whole 1 request, that is to say that no postback operations work in the slightest.  I set up my entity data source, enabled updates/deletes/inserts, and I can click anything I like, but nothing actually seems to interact with the data source.  I see the following events on deleting for example:
    1. Click delete
    2. Grid deletecommand event fires, where all references to the data item in question are null
    3. No call to data source events
    4. NeedDataSource is called
    5. Result - no effect

    Binding through NeedDataSource
    This can not possibly be the recommended approach!  Everything becomes manual to the point of complete frustration and the only benefit I get from the grid is it looks pretty!  Everything from Sort Expressions, to grouping, to OH MY WORD filtering (what a nightmare) becomes a hassle from hell.  What the heck is the idea behind using dynamic linq expressions for filtering???  Can't you just spit out some predicates or something.  Yeah it might not be that simple, but you guys have a heck of a lot of developers there.

    Entity Framework is I admit newer than sql, but come on, it's not that new!  It's not like we're on CTP V1, we're now expecting V5 of Entity Framework and apologies, but it's high time telerik caught up.  It's starting to feel like the ASP.NET controls are losing funding and you guys are on your way to retiring them.  If that's the case, please just say so, so I can go out and advise clients to move to a different control suite if they want to build ASP.NET apps.

    By the way, don't get me wrong, I've been a Telerik fan for a long time, and Sitefinity, Kendo, and the rest of your product line are all pretty fantastic (OpenAccess is an odd one, but you can't do everything perfect!! :)

    I appreciate that this post is about 40% fuelled by a tired mind frustrated at not being able to accomplish what I'm trying to do, but that should also be a concern for you.  If I can't find what I need from your forums, documentation and examples, I'm not going to be a happy customer... oh wait, that's exactly what I'm not right now!

    Please help me keep some of my hair from going grey.  Obi Wan Telerik, you're my only hope!

    (p.s I know this post is devoid of code examples, but if I was to post all the things I've tried, I'd cause out of memory exceptions in your web server or disk space problems for your dba's, so if you can point me in the right direction, I'll let you know where I've been already down that road.)
  2. O.D.
    O.D. avatar
    13 posts
    Member since:
    Nov 2008

    Posted 23 Jul 2012 Link to this post

    Hello Adam,

    I am not an employee of Telerik, but more a customer, and a long time user of Telerik for asp.net ajax.

    Our company relies totally on those components for now, which helps us stand out often, when it comes to UI and ease of use.

    Asp.net web forms, and Telerik for asp.net ajax, may seem, like they are not evolving, yet, they  are, just not as much as MVC for the moment.

    As for the EntityDataSource vs NeedDataSource :

    In depends on the cases. If you are developing in a somewhat direct way (meaning : The Control / the data source / the binding / Filtering), all in the aspx page, The EntityDataSource will do.

    As for The NeedDataSource, it is used, when your only way to get to the data source, is through code.
    That is the case of my employer : Everything is dynamic, from Columns, to rows, and the data source. This is one reason, we only use NeedDataSource event, and no data source controls like The EntityDataSource.

    As for POCO : It is a feature available in Entity Framework, but not related to Telerik controls. With POCO, yes you definitely get simple objects, and in this case, no need for the EntityDataSource.

    It would be best, to choose one technique Based on requirements, and some sample Code (which could be posted on the forum). That would provide you with more detailed answers.

    And finally, It was frustrating to get the mechanics of binding with Entity Framework at first.

    I hope I did not cause more confusions :)

    Kind Regards,
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Adam
    Adam avatar
    4 posts
    Member since:
    Mar 2005

    Posted 23 Jul 2012 Link to this post

    Hi O.D.,

    Thanks for the reply.  I agree that Telerik are pretty much awesome products, which is why I find the lack of clear support for EF so strange, and kinda annoying :)

    So basically what you're saying is that using code first POCO's, I should use the NeedDataSource event.  The question then is how to you handle things like sorting, filtering and grouping?  Just for sorting, I could end up with reams of code to convert a string column name, and order direction to a strongly typed linq OrderBy query for my DbSet.  And I don't even know how I would handle filtering and grouping.

    So do you or does anyone else have any idea how I would handle all those things manually with a reasonable amount of code?  It just seems the controls are significantly built for use with data sources.

    Thanks,
    Adam.
  5. O.D.
    O.D. avatar
    13 posts
    Member since:
    Nov 2008

    Posted 25 Jul 2012 Link to this post

    Hello Adam,

    Best is to create a simple code example. you may not find code samples for CodeFirst here. 

    You are not obliged to use CodeFirst. POCO's can be used without CodeFirst. Best is to first leverage, what to use in Entity Framework.

    With POCO's, you can use either an ObjectDataSource or simple C# binding combined the NeedDataSource Event.

    I hope you are advancing somewhat. 

    For Entity Framework, it is not mandatory to use it, in all cases. Also, if you have complex queries, you can still go through stored procedures directly.

    I wish someone could add a code sample on this. I need some time, but will definitely build a sample and post it soon.

    Kind Regards,
  6. Peter
    Peter avatar
    98 posts
    Member since:
    Mar 2012

    Posted 09 Nov 2012 Link to this post

    I want to use the EDMX model-first style of Entity Framework - are there any code examples with Telerik controls?
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Nov 2012 Link to this post

    Hi,

    Check the following demo which explains how to use Entity Framework with RadGrid.
    Grid / Entity Framework Manual Operations

    Thanks,
    Shinu
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017