开发者

CRUD Operations in a C# WFP Windows application that interacts with ADO Entity Model

I've setup an ADO entity model for my Windows application, and am able to get the data out of the tables that I need. However, when I try to update/insert/delete it just doesn't like the code that I'm using, but that would be that I'm not sure I'm doing it right, or even close to right.

My confusion is that I learned WPF with silverlight and Ria serivces, so what I have done in my application is that I've setup my model, and I have created domain services. This works for getting the data out. Here is my code, as well as what is needed in silverlight:

Windows:

WebsiteProfileService wps = new WebsiteProfileService();
cbProfile.ItemsSource = wps.GetWebsite_Profile();

where wps is my profile serivce that I have created, and cbProfile is a combo box that is now populated with the different options.

Likewise, is silverlight it would go something like this:

WebsiteProfileService wps = new WebsiteProfileService();
...
LoadOperation<Website_Profile> loadPro = wps.Load<Website_Profile>(wps.GetWebsite_ProfileQuery());
loadPro.Completed += new loadedeventhander(loadPro_Completed);

void loadPro_Completed(sender, e)
{
    cbProfile.Itemsource = wps.Website_Profile;
}

Now, there are shorthand ways of doing that query, but this isn't a silverlight question, I think.

Now, in that same vain, to update,insert, delete an object I would do something like the following in silverlight:

//Create the object
Website_Profile wp = new Website_Profile{
Name = Test,
Value1 = 10,
};

wps.Website_Profile.add(wp); // this adds it to the entity
wps.submitchanges(); //this submits data back to the database

Anyway, that's how I've come to expect this to work, but now I'm not presented with the options to submitchanges(), or even have wps.Website_Profile as an option...

I do have access to a wps.Submit() but it doesn't take 0 values, and wants something about a changelog, and that is something I haven't run into yet.

If you know any information, or tutorials online t开发者_StackOverflowhat can help me, please let me know, all my google searches have pointed me to silverlight, which isn't what I'm needing right now.

Or, if you know of a better way to have a windows application interact with a database in a WPF application I'm all ears, but I might have a few follow up questions. :)

Thanks for your time,


Linq to SQL is a lot easier to use than Entity Framework, and probably a better fit for your first applications. Don't burden yourself with learning too many things at once.


Perhaps, you can use domain driven design here with repository pattern? Very simple explanation of repository pattern can be found here, and this conversation has many useful links on the topic.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜