VS Live 2013 in Las Vegas

As I mentioned before, I spoke at VS Live 2013 in Las Vegas last week.  I spoke on two topics

Entity Framework Code First End to End

This session will cover the use Entity Framework in .NET based applications. Discussion will include model creation and organization as well as schema evolution via migrations. The role of data annotations in Entity Framework model creation and validation will be highlighted. Key issues in achieving performance will be part of the talk, including ability to embed stored procedures when necessary. Creation of a maintainable data access layer via use of repositories will be illustrated. An ASP.NET MVC application will be built throughout the talk to illustrate the concepts.

Learning objectives

  • Schema creation and schema evolution
  • Key aspects of achieving high performance
  • Repository pattern with entity framework code first

You can download information by following the links below

WCF Data services – getting started guide

This session will concentrate on how to get started with WCF data services, Microsoft technology that implements OData standard. Topics such as authentication types and authorization via interceptors will be covered. Query building will be discussed via proxies and via URLs. Creation of service operations will be covered. Entity Framework Code First and Database First approaches will be talked about. A WinRT / Win 8 XAML application will be built to demonstrate the use of OData client to consume the data.

Learning objectives

  • Create a basic WCF data service with data and operations
  • Understand authentication and authorization
  • Implement CRUD operations from WinRT Client

You can download information by following the links below

 

I also recorded both presentations.  You can check them out on my YouTube channel.

12 Comments

  1. Hello,
    I have a question concerning tracking of DataServiceContext.

    Using your function:

    var query = (DataServiceQuery)_chinookEntities.Artists.Where(one => one.Name.ToUpper().Substring(0, 1) == letter.ToUpper());
    var data = await query.ExecuteAsync();

    the response is in Atom format,

    Is it possible to get the response in JSON?

    Thank you for an answer.

    Frank

  2. thanks for your answer,

    … My problem is, that I do have many controls with twoway binding to da DataContext which I get from a WCF DataService. So, I need change Tracking which I obviously do not get with HttpClient.

    With DataServiceQuery I do have Tracking, but no JSON response.

    Am I right or is there any other way to meet both demands?

  3. You can certainly add a cookie to all WCF data service requests. There is a client event called SendingRequest that you can subscribe to and inject your cookie in every request that way.

  4. very good – that works!

    Now I tried to get JSON data and extend the code like this:

    void OnSendingRequest(object sender, SendingRequestEventArgs e)
    {
    e.RequestHeaders[“Accept”] = “application/json;odata=verbose”;
    e.RequestHeaders[“Cookie”] = TMSDataSource.Cookie.ToString();
    }

    Then I get the Exception:
    The ‘Accept’ header must be modified using the appropriate property or method.

    Obviously, this is not the right way of doing but unfortunatly I am not skilled enough to know what to do.

  5. I do not think you can set Accept header like this. There should be method on the web request that exposes accept header. You can just remove that one line to confirm or change your code to do something like e.Request.Accept = ”’

  6. I found another OnSendingRequest2 and tried this:

    void OnSendingRequest2(object sender, SendingRequest2EventArgs e)
    {
    e.RequestMessage.SetHeader(“Accept”, “application/json;odata=verbose”);
    e.RequestMessage.SetHeader(“Cookie”, TMSDataSource.Cookie.ToString());
    }

    Now, I get a NotSupportedException:

    ‘application/json’ is currently not supported in Content-Type header

    Do I have to wait for next versions? I do have

    Microsoft.Data.OData.WindowsStore 5.0
    Microsoft.Data.Services.Client.WindowsStore 5.0

  7. I do, but there are only 2 Events to use with DataServiceContext:

    SendingRequest with SendingRequestEventArgs which only has the property RequestHeaders
    SendigRequest2 with SendingRequest2EventArgs which has the properties RequestMessage and Descriptor

    Using SendigRequest2 and setting the header with

    e.RequestMessage.SetHeader(“Accept”, “application/json;odata=verbose”);

    do work, but during query.EndExceute the NotSupportedException is fireing.

    public static async Task<IEnumerable> ExecuteAsync(this DataServiceQuery query)
    {
    var queryTask = Task.Factory.FromAsync<IEnumerable>(query.BeginExecute(null, null), (asResult) =>
    {
    var result = query.EndExecute(asResult).ToList(); <=========================
    return result;
    });

    return await queryTask;
    }

  8. Pingback: Entity Framework – Code First – More EF | avalondarren

Leave a Reply

Your email address will not be published. Required fields are marked *