Michells Mesterværk

WCF Data Services

by Administrator 11. February 2010 09:16

Med .NET 4.0 er ADO.NET Data Services blevet til WCF Data Services.

Med WCF data services kan du både konsumere datakilder og stille datakilder til rådighed, uanset om det er in-memory objekter eller fra relation databaser. Når du bygger en data kilde op fra f.eks in-memory objekter vil de blive tilgængelige over et REST interface som man kan tilgå fra hvor som helst (så længe “hvor som helst” kan parse XML).

WCF Data Services er utrolig fleksibelt og faktisk super nemt at gå til, det kræver faktisk ikke meget kode at prøve det af. File –> New –> Wcf Data Service:

using System;
using System.Data.Services;
using System.Data.Services.Common;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Web;

public class UsersDataService : DataService<UsersContext>
{
    public static void InitializeService(DataServiceConfiguration config) {
        config.SetEntitySetAccessRule("Users", EntitySetRights.AllRead);
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
    }
}

public class User
{
    public int ID { get; set; }
    public string Username { get; set; }
}

public class UsersContext
{
    static List<User> _users;

    static UsersContext() {
        _users = new List<User>() { 
            new User { ID = 1, Username = "Daniel" }, 
            new User { ID = 2, Username = "Henrik" } 
        };
    }

    public IQueryable<User> Users {
        get { return _users.AsQueryable();  }
    }
}

Højreklik og vælg “view in browser”. Nu vil du få det data ud som er i vores in-memory objekt, som XML.

Hvis du gerne vil se mere omkring WCF Data Services vil jeg forslå du ser disse screencasts igennem.

 

(ADO.NET Data Services baseret på en Non-Relational Data Source)

(ADO.NET Data Services baseret på en Relational Data Source)

Tags:

Udvikleren.dk | VS2010

Comments

2/14/2010 1:56:40 PM #

اخبار

Thank you very much for the possibility to have a look into the office. Nice boy, he has got the talent to explain.

اخبار Egypt

2/14/2010 2:01:54 PM #

اخبار

Thank you very much for the possibility to have a look into the office. Nice boy, he has got the talent to explain.

اخبار Egypt

2/24/2010 11:29:53 AM #

Rodolfo Bollom

Most testers find themselves outnumbered by devs. In my example it’s virtually 10 to 1. (The preferred ratio is a beat discourse I’d like to avoid in this post.) Instead, I would like to bitch about a problem I’ve discovered as I gather more projects to test. Accepting my ten devs are spread between five projects (or app modules), each dev must attend to merely the Feature Review/Design group meetings for the project they are accountable for. Nevertheless, the tester must pay heed all five. Do you see a problem here? Let’s do the mathematics for a 40 hour work week. If every project’s Feature Review/Design meetings occupy eight hours per week, every dev will own 32 hours left to write code. Each tester is left with ZERO hours to run code! The above-mentioned scenario is not that much of an exaggeration for my team. The tester has no alternative but to skip some of these meetings just to squeeze in a little testing. The tester is asked to "stay in the know" about all projects (and how those projects integrate with each other), while the dev can frequently concentrate on a single project. I believe the above problem is an oversight of numerous managing directors. I doubt it gets noticed because the testers' time is being nickel and dimed off. Yet most testers and managers will assure you, “It’s a no-brainer! The tester should go to all design reappraisals and feature walkthroughs…testing should commence as early as possible”. I concur. But it is an irrational anticipation if you staff your team like this.

Rodolfo Bollom United States

2/28/2010 3:18:28 AM #

money

Awesome blog it's not often that I comment but I felt you deserve it.

money United States

2/28/2010 11:33:01 AM #

stock charts

Have your thought about adding some social bookmark buttons to your site? You should at least add one for Digg so we can digg you up!

stock charts United States

3/4/2010 6:22:39 AM #

free hd movies

I like watching movies online, it is way easier than going to the theaters.

free hd movies United States

3/7/2010 7:48:33 AM #

games online

Hi admin, your site's design is simple and clean and i like it. Your articles are so cool. Please keep up the good work. Sincerely...

games online Turkey

3/9/2010 8:43:58 PM #

WoW Mobile

Do you know which cell phone companies allow tethering?

WoW Mobile United States

3/17/2010 12:03:01 PM #

arac sorgulama

I admire the valuable information you offer in your articles. I will bookmark your blog and have my children check up here often. I am quite sure they will learn lots of new stuff here than anybody else!

arac sorgulama United States

3/19/2010 10:42:36 AM #

wow leveling guide

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon.

wow leveling guide United States

3/20/2010 3:37:22 PM #

ehliyet

Excellent post.I want to thank you for this informative read, I really appreciate sharing this great post. Keep up your work.

ehliyet Denmark

4/3/2010 9:52:19 AM #

wow leveling guide

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon.

wow leveling guide United States

4/7/2010 4:02:16 AM #

Gene Sarwary

It does seem that everybody is into this kind of stuff lately. Don’t really understand it though, but thanks for trying to explain it. Appreciate you shedding light into this matter. Keep it up

Gene Sarwary United States

4/7/2010 9:31:39 PM #

GA Payday Loans

You will get all you want in life if you help enough other people get what they want.

GA Payday Loans United States

6/6/2010 2:51:18 PM #

Promotional Products

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon.

Promotional Products United States

6/6/2010 2:53:41 PM #

Promotional Products

Do you know which mobile phone companies allow tethering?

Promotional Products United States

6/6/2010 2:54:39 PM #

Promotional Products

Please let me know if you are looking for a writer for your blog. You have some good content and I think I would be a good asset.

Promotional Products United States

6/14/2010 9:54:16 PM #

discount dog supplies

Most testers find themselves outnumbered by devs. In my example it’s virtually 10 to 1. (The preferred ratio is a beat discourse I’d like to avoid in this post.) Instead, I would like to bitch about a problem I’ve discovered as I gather more projects to test. Accepting my ten devs are spread between five projects (or app modules), each dev must attend to merely the Feature Review/Design group meetings for the project they are accountable for. Nevertheless, the tester must pay heed all five. Do you see a problem here? Some discount dog supplies are here for you.

discount dog supplies United States

7/20/2010 4:42:18 AM #

Vietnam Visa

First I would like to thank you for posting such a beautiful article.

Vietnam Visa United States

7/23/2010 3:34:39 AM #

cell pay as you go

så hvor har du at sende data ved hjælp af WCF datatjenester? har du at sende til en slags web-side?

cell pay as you go United States

Add comment


(Will show your Gravatar icon)

(De 3 specielle karaktere i det danske alfabet?)
  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen