DataSource Controls :: Entity Framework And Architecture Of Model - Create Application Using EF

Feb 10, 2010

I can't to understand clearly how to create strong and quickly application using EF. For example, I have class ForumPost (table ForumPost) for select one of record I write method like:

public ForumPost ForumPost(int ForumPostID)
{
return
(from i in _dataContext.ForumPostSet
where i.ForumPostID == ForumPostID select i).First();
}

all works. But on page (I use ASP.NET MVC) I should display info from another linked tables, ForumName (each post have ForumID) etc. So, I modify this method to:

public ForumPost ForumPost(int ForumPostID)
{
return
(from i in _dataContext.ForumPostSet
.Include("ChildPosts").Include("ParentPost").Include("Users").Include("Forums").Include("Tags").Include("ForumPostPolls")
where i.ForumPostID == ForumPostID select i).First();
}

ok, all works. Then I want to make some actions in model with ForumPost, i.e.

public void RootPost(int PostID, ref Models.ForumPost Root)
{
ForumPost post = ForumPost(PostID);
if (post.RootPost != null)
{
Root = ForumPost(post.RootPost.ForumPostID);
}
else
Root = post;
}

it works too. But problem is in speed. I not need in RootPost all those includes. So, I should to create one more method like:

private ForumPost ForumPostIncludes1(int ForumPostID)
{
return
(from i in _dataContext.ForumPostSet
.Include("ChildPosts")
where i.ForumPostID == ForumPostID
select i).First();
}

then ForumPostIncludes2, ForumPostIncludes3 etc... second way - redesign RootPost with LINQ expr, not with call another method. But in this way difficulties to change DB. third way? How to do it correctly?

View 1 Replies


Similar Messages:

Architecture :: Entity Model Design Framework And N - Tier Architecture

Dec 25, 2010

recently i've studied on ADO.NET's Entity Model Framework and say 'wow' as ORM is one of the fevourite pattern i practice..but suddenly i've come to an ambiguous situation when i'm going to start. i usually follow the following 3-tier architecture..

1. UI Layer
2. BLL - business logic layer
3. DAL - Data Access Layer
a. DTO / DAO
b. Gateway (contains the sql query/stored procedure and connection with DB)

now when i'm going to use the Entity Model Design,where the DBML/ .edmx File should be placed? Because many a times i'm using the DBML file as DTO because of the mapped objects.. in the same time, sometimes DBML ( .edmx file in .NET 4.0) contains CRUD methods and stored procedured method as well as methods with different selection operations,- which should be in Gateway. so where the .edmx file should be placed !?!! IN DTO namespace !? or in Gateway namespace!

moreover sometimes there is no need for the BLL which breaks the rules of inter-layer-communication (UI > BLL > DAL.Gateway)! what makes me confuse is, what should be the ideal n-tier architecture when i'll use the ADO.NET Entity Model Design Framework

View 4 Replies

What's Mvc Model In Software Application Development And Entity Framework

Apr 2, 2010

Generally what is m.v.c model in software application development and entity framework in asp.net and are these diffrent form 3 layer d architecture(UI layer, Business access layer, Data access layer)

View 2 Replies

Exporting Entity Framework 4 Data Model To Entity Framework 3.5?

Oct 25, 2010

Is there a way to export a EF 4.0 Data Model to EF 3.5?

I looked around and found that we are not able to access EF 4.0 from a ASP.Net 3.5 project here: [URL]

Our project is the 1st to go to .Net 4.0 using Entity Framework and we (the team) were wondering if there was a way for the other projects that "might" need to access our data that are still using the .Net 3.5 framework.

View 1 Replies

DataSource Controls :: How To Create A Self Association Relation For An Organization Chart Data Tree In Entity Framework

Mar 6, 2010

I,am trying to create a self association relation for an organization chart data tree in Entity Framework,after trying different ways for prevention of exceptions like 3007 and etc. I found that when I put my foreign key in my POCO near Parent and Items navigation properties its work.but I think this is not correct that we have both ParentID scalar property and Parent navigation property. review this and tell me is it correct or not.I'm using VS 2010 RC and ofcource .net framework 4.0 RC

[Code]....

View 2 Replies

MVC :: Possible Model Not Based On An Entity Framework

Jun 11, 2010

There are some tutorials explaining how to create a Model based on Linq to Sql or The Ms Entity Framework. Can I use my custom code for a model? If we have the controller with the code :

[Code]....

This returns a List<Movie> to the view that knows what to do with it. Is it possible that I create a method called MovieSet that returns a List<Movie> using a sql qry or a stored procedure call without the creation of an Object for this purpose ? Or do I need a Movie object? Lets say that I just to do my query, loading data into a dataTable and load that data to a list of movie objects. Because the code created by the Entity Framerwork is too big for a quick reading.

View 4 Replies

Entity Framework Model For Oracle

Mar 29, 2011

I want to use entity framework model for visual studio 2010. I am using oracle database. i was wondering if it is possible to use entity framework for oracle. If it is not possible then I will just use simple ADO.net and call stord proc and packages. I already downloaded oracle data provider for entity frameowrk from codeplex web site. I could not see oracle database option when connecting to oracle databse in LINQ to sql. can someone give me any example that connects to a sample oracle database and use LINQ to oracle

View 1 Replies

Wcf - SOA Architecture For .NET With Entity Framework

Apr 1, 2011

I am redesigning a Solution's Architecture to implement SOA.

After doing the design changes I have come up with:

MySolution.Client.MyProject.Web ...... //ASP.NET WebSite
MySolution.Client.MyProject.Proxy .... //Service Proxy C# Library Project *[1]
MySolution.Service ................... //Service.cs for Service.svc is here
MySolution.Service.DataContract ...... //IService.cs for Service.cs is here *[2] [code]....

This project contains IService and Request/Response Classes

All methods in Service.cs takes the Request classes as input and return Response classes as output

Therefore this project is referenced by the 2 Client Projects(Web and Proxy), as it contains the IService and all of the Request/Response classes that will be required to communicate with Service.cs

*[3]MySolution.Model: This project contains the .edmx that is the Data Model of Entity Framework and some custom classes that are used in the project.

PROBLEM: Because I only use Request/Response classes to communicate between service and client, The MySolution.Service.DataContract project is only used by Service.cs and Repository.cs

And due to that all responses that Repository generates i have to map them to the properties of its respective response class (which make both the original returned entity, and the response class almost identical). But i am OKAY with it ...

e.g: GetCustomer() in Repository.cs method is called by Service.cs

GetCustomer() method in repository performs the LINQ query and return a "Customer" object

Service.cs then maps all the properties of "Customer" object to the "CustomerResponse" object

Service.cs then returns the "CustomerResponse" to the caller.

in this case most of the properties will repeat in both classes, if there is solution to this, its good, otherwise, I am fine with it.However, when Repository.cs's method GetCustomers() (Notice its not GetCustomer()) is called, it will return List of Customer object, and mapping this for return purpose would mean a "for loop" that iterates the collection and do the mapping ... this is NOT OKAY ...

is there any better way of doing this, considering I do not want to return "Customer" object without "CustomerResponse" as first of all it violates the SOA architecture, and secondly I don't want my Client Projects to have any reference to the Model or Repository projects.

View 3 Replies

Architecture :: Entity Data Model Not Refreshing

Jun 9, 2010

We're upgrading our system core asp to asp.net mvc, but there is a problem with refreshing the Database Model, our system is a UDP listener Windows Service, and Instering data to our database, our web system reading the database and process it then render. Here is the problem, When i enter some data using DatabaseModel, there is no problem, but when Windows service insert records to database, i can see the record at the web, is there a way to refresh entity data model/

View 4 Replies

ADO.NET :: Using Stored Procedures In Entity Framework Model

Sep 2, 2010

i am calling stored procedure through entity model like result=ctx.spname(parmas), i am expecting 0 or 1 as a result after the execution of sp, but its returning unknown values like 178 for number records.

View 2 Replies

Architecture :: Advantage Of Using MVC And/or Entity Framework

Oct 2, 2010

I am new to Entity frameworks-EF. As, EF is built on top of ADO.NET...If so, will there be any performance issue when we use it?Same way MVC also targets Test Driven , rapid application development only ..What speciality does it add for end-users?As per my understanding ASP.Net 2.0 itself is powerful without MVC and/or EF...

View 7 Replies

Architecture :: Integarting ADO.NET Entity Model With Windows Workflow?

Jun 25, 2010

how can I integrate ADO.Net Entity Data Model with windows workflow.

View 1 Replies

ADO.NET :: Entity Framework Dynamic Model (change At Runtime)

Mar 18, 2011

I am making a web project now. And i meet some problems working with Entity Framework. My program needs to have dynamic model. I try to explain. So i have classes and database is created from them. At the beginning of work program checks in folder Modules for assemblies and looks for classses that needs to be created as tables in database(this classes have to become a part of ef model). And i need at runtime create database.If some new classes was added so add this tables to database, but not recreate it(as it is made by default). If i delete classes the tables are not deleted.

View 2 Replies

Generate Entity Framework Model From Client Side?

Feb 27, 2010

Can I generate entity framework model by clicking button in browser in client-side and save it back to web server PC?

View 2 Replies

ADO.NET :: Use Entity Framework Model For Visual Studio 2010?

Mar 28, 2011

I want to use entity framework model for visual studio 2010. I am using oracle database. i was wondering
if it is possible to use entity framework for oracle. If it is not possible then I will just use simple ADO.net and call stord proc and packages.I already downloaded oracle data provider for entity frameowrk from codeplex web site.can someone give me any example that connects to a sample oracle database and use LINQ to oracle

View 1 Replies

Architecture :: Entity Framework With 3 Layers Design

May 19, 2010

I am thinking to use entity model as DAL, how should I create the BLL then? What kind of datasourceobject should I use in the asp pages?

I am looking for best practice to use Entity framework 2 in the three layers design. I had experience at dataset with three layers design.

Should I use objectdatasource at the pages for gridviews? My guess is that entitydatasource by passed the BLL which is not good, so the only option left is the objectdatasource.

Could and should my BL object inherit those entity model in the DAL, so I dont need to recreate their object's property?

View 4 Replies

ADO.NET :: Fill .aspx Textbox From Entity Framework Model In VS10 C#

Jan 6, 2011

I am using C# with Entity Framework Model. I want to fill a textbox (tbPrepProbComment.Text ) with a string (S0PrepProbSolveComment) from a table (EightDProject). I'm getting the key for the EightDProject from a textbox (SelectTrackingNumber). I'm not sure my query is working because when I look at the query result ( project ) I see the error" 'mykey' could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly." If the query was working I dont know how to pull the field from the distinct row it should return and put it in the textbox. I've tried the line tbPrepProbComment.Text = project.S0PrepProbSolveComment; Here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Objects;
namespace EightD1
{
public partial class Page1 : System.Web.UI.Page
{
public int mykey;
public string comment;
public object obj;
// the entity framework model
EightDdbEntities EightDP = new EightDdbEntities();
protected void Page_Load(object sender, EventArgs e)
{
SelectTrackingNumber.Focus();
}
//When the project id has been selected get projectdata and bind to page data holders
protected void SelectTrackingNumber_TextChanged(object sender, EventArgs e)
{
BindData();
}
private void BindData()
{
try
{
mykey = Convert.ToInt32(SelectTrackingNumber.Text.ToString());
}
catch
{
mykey = 0;
}
ObjectQuery<EightDProject> project = EightDP.CreateQuery<EightDProject>(
"SELECT DISTINCT p FROM EightDProjects AS p WHERE p.EightDID = mykey ");
//tbPrepProbComment.Text = project.S0PrepProbSolveComment;
}
}
}

View 2 Replies

C# - How To Start With Entity Framework And Service Oriented Architecture

May 12, 2010

At work I need to create a new web application, that will connect to an MySql Database.

(So far I only have expercience with Linq-To-Sql classes and MSSQL servers.)

My superior tells me to use the entity framework (he probably refers to Linq-To-Entity) and provide everything as a service based architecture. Unfortunately nobody at work has experience with that framework nor with a real nice server oriented architecture. This speficic project I'm leading will be long-term, meaning multiple years, so it would be best to design it the way, that multiple target plattforms like asp.net, c# wpf, ... could use it)For now, the main target plattform is ASP.net

So I do have the following questions:

1) Where can I read best what's really behind service oriented architecture (but for now beginner tutorials work fine as well) and how to use it in best practise?

2) So far I can't see a real difference between Linq-To-Sql classes and the information I've googled so far on the 'entity framework'. So, whats the difference? Where do I find nice tutorials for it?

3) Is there any difference in the entity framework regarding the database server (MSSQL or MySQL)? If not, does that mean that code snipperts I will stumble across will word database independent?

View 3 Replies

Architecture :: Data Binding To Entity Framework Classes?

Feb 1, 2011

I am using the ADO.NET Entity Framework for loading data from the database. The classes are directly mapped to database tables in the database. The problem is that these classes are not optimal for binding to the UI elements. As a result of this I have some custom entities which are populated at the service layer and returned. It is these custom entities (classes) to which I bind the UI elements. My questions on this are1. Is populating these entities at the service layer the most appropriate way to do this. I personally do not think so because if we introduce some additional UI elements which need different entities then I have to modify the service layer again.2. What is the best approach/pattern to get this done.

View 2 Replies

Web Forms :: Implement Three Tier Architecture In Entity Framework 4.0

Nov 9, 2012

Any good example of Three tier architecture in entity framework 4.0 ...

View 1 Replies

DataSource Controls :: Two Tables In MVC Using ADO Entity Data Model

Apr 6, 2010

my application have two tables. TableA and TableB TableA have one record

ID StudentName Age
1 MARK 20

I use selectlist to select StudentName .

ViewData["StudentName"] = new SelectList(_db.StudentSet.ToList(), "StudentName", "StudentName");

and then add to TableB. for this case , for me is success, but I also want to add the"Age" into TableB on same time. I don't know how to do it.

View 3 Replies

ADO.NET :: Insert Update And Delete Records Using Entity Framework Data Model?

Nov 22, 2010

How can i insert,update and delete records using entity framework data model.

View 1 Replies

Architecture :: Ado.net Entity Framework - Query - Return Correct Data

May 26, 2010

I just tring to a complex (for me) with ado.net entity framework this is the structure: In practice it is a sort of group purchasing (Buyers) For each group of purchase (Buyer) should have the opportunity 'to select all products of the brands indicated in buyer I'm doing function to return correct data like this:

public List<Product> GetProductsByBuyer(int vBuyerId)
{
Buyersctx.Products.MergeOption = MergeOption.NoTracking;
return (from lProduct in Buyersctx.Products.Include("Brand").Include("Buyers")
where select lProduct).ToList();
}

View 2 Replies

Visually Set Controls Datasource From Entity Framework?

Feb 27, 2011

I set up Entity Framework for my Table and Stored Procedure to return data. Created a Domain Class as well.

In Domain Class, I am returning Objects as collection.

On .Aspnet page when I drop a Control(Combo,Dropdown) I can set up the source for the controls visually if the source is table.

However, In domain class I have stored precedure object that return collection of data And I cant not set up visually from Designer, I am only available to write code behind. is it possibble that i can set up from desingner.

View 6 Replies

DataSource Controls :: WEB Services And Entity Framework?

Jan 19, 2010

CAN we use Entity framework in web services.I the following error while the code connects to the database using entity framework

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved