DataSource Controls :: LINQ Mapping To Complex Business Objects?
Feb 5, 2010
I have two business objects mapped via LINQ to tables. One of the objects contains an instance of the other object and share a key as an identifier.I want to retrieve Class A and within class A all of Class B's values as well. What I am doing is this:
[Code]....
[Code]....
This seems a little clunky, as in slow. Is there a better way to get the Class B (User) information without making a query every time?
View 4 Replies
Similar Messages:
Sep 2, 2010
As I began writing web applications with asp.net I started with small projects that used a Linq-To-SQL mapper for database access to a MSSQL Server. After gaining some expierence I switched into a classic 3 tier with Graphic Layer, Business Layer, Data Layer. The only function of the Data Layer was to provide methods insert/update/delete without any logic and logic the form of selection methods.
Over the time I realized that it would be better not to provide the database classes up to the GUI (took some time unfortunately). I switched into using Business classes in the BL that are used for all operations performed by the BL and display by the GUI in the form of getting List from the BL. A great advantage is that I can provide additional properties that are not represented by the database itself. However, I did that mapping inside the BL myself with methods that mapped the corresponding BL class to the database class.
I guess thats where O/R mapper come in handy? Until now I haven't realized their purpose, but I think I just found it. I've recently tried out using the new Entity Framework with .net framework 4, but I'm only using it like the Linq-To-SQL DataContext.
Is there a way to achieve the mapping automatically? If yes, is that something the new Entity Framework provides or do I need to look for a O/R Mapper like NHibernate?
View 4 Replies
Mar 26, 2010
I created a class library: PRTreatmentReviews. I created a reference for the class library on the website. I checked the property pages and the reference to the class is there. I put objectdatasource on a page and tried to pick up the PRTreatmentReviews class but it's not there? The Class
[Code]....
View 13 Replies
Apr 5, 2010
Entity framework easily allows for this but how can I detach objects in linq to sql?
View 1 Replies
Mar 10, 2010
I have a really weird problem. It actually made me restart the computer.
View 1 Replies
Mar 18, 2010
I have a problem. (this a simplfied example)
In Entity framework I have a class which is effectively
fooEntity
{
public Guid Id {get; set;}
and a collection of fooChildEntity
}
a fooChildEntity is again an entityframework class
fooChildEntity
{
public Guid kidId {get; set;}
}
Now I also have a pair of business layer classes foo and fooChild
foo
{
public Guid Id {get; set;}
ilist<fooChild> Children {get;set;}
}
fooChild
{
public Guid kidId {get; set;}
}
My aim is to write a linq to entites that will allow me to convert the entity foo and children into the business foo and children without breaking deferred execution ( I will be adding filters to reduce the recordset at a higher coding level in the business layer)
doing something like
this.context.fooEntity
.include(fooChildEntity)
.Select( fe => new foo { Id=fe.Id ,
fe.foreach(fec => Children.add( new fooChild { kidId = fec.kidId}))})
.AsIQueryable()
is plainly rubbish and would never compile - it is however an indication of the direction I was thinking .
Even if I got a foreach to work like that or similar it would break deferred execution
At this point there are around 300,000 foo entities which I will eventualy filter to 5 or 6 foo's - this is why deferred execution is needed.
View 1 Replies
Mar 18, 2010
I would like to write Set difference minus operation with Linq on list objects using Except method. [Code]....
Tha above code always returns lstrbb objects.
View 2 Replies
Apr 1, 2010
I have a data object where one of the properties is a collection of another data object. I never really figured out how to map this to a GridView, but I came up with a workaround. Now I am stuck and cannot figure out any way to do this in a ReportViewer.
Here is how I solved the GridView issue:
Say we have these objects:
public class BoysWithToys : List<BoyWithToy>
{
}
public class BoyWithToy
{
string FirstName { get; set; }
string LastName { get; set; }
int BoyNumber { get; set; }
List<Toy> FavoriteToys { get; set; }
}
public class Toy
{
int BoyNumber { get; set; }
string Toy { get; set; }
}
What I wanted to do was to map BoysWithToys to the GridView and present one GridView row per BoyWithToy record. Where there was more than one FavoriteToys record I wanted to list them in a bulleted list in the FavoriteToys column. I accomplished this by calling RowDataBound() for the GridView, casting the e.Row.DataItem to BoyWithToy, then looping through all of the FavoriteToys and adding each Toy to a bulleted list, then setting the column's text to that list.
I have no idea how to accomplish anything similar in ReportViewer. If I simply drag the BoysWithToys DataSource to the designer and run it, the FavoriteToys column shows '#Error'.
View 3 Replies
Aug 10, 2010
I'm having a trouble figuring out how I am going to map my business objects. I found this little mapper using reflection with a little modification :http://www.simple-talk.com/dotnet/.net-framework/a-defense-of-reflection-in-.net/Above works fine and fill out my Business objects properly. But what if I have relationship on the Business objects class like for example :
[Code]....
then a User Class will have a relationship with Roles like :
[Code]....
Assuming there are columns on the database that have the RoleID, RoleName, UserID, UserName by Joining the 2 tables. The problem here is that the Mapper doesn't map the Roles properly since the Mapper will expect a Column Name "Role". I tried also inheriting the roles instead of instantiating it but it doesn't work either.I'm using a 3-tier Architecture (including a sublayer "Business Objects") and List<T> combo.
View 10 Replies
Feb 24, 2010
I'm working on a project in which we have a database, data layer (entity framework), business layer and web/UI layer.I want to use ASP.NET Dynamic Data for the web layer, but don't want it to access the data layer or database, as I want it to be purely running off business logic, and not directly accessing the data.However, it appears that Dynamic Data only allows Linq-to-SQL or entity framework data sources to be used.Has anyone used it with business-layer objects instead?
View 1 Replies
Jul 23, 2013
I am trying to call web service from jquery..trying following way but i am not able to pass to complex type parameter to WCF service.My wcf function is as follows
<OperationContract()>
<Web.WebGet(UriTemplate:="/GetData?strErrMsg={strErrMsg}&chrErrFlg={chrErrFlg}", ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Wrapped)> _
Function GetData(ByRef strErrMsg As System.Collections.Generic.List(Of String), ByRef chrErrFlg As String) As String
strErrMsg is System.Collections.Generic.List(Of String)
I am trying to call as follows
var Type;
var Url;
var Data;
var ContentType;
var DataType;
var ProcessData;
var parameters;
[code]...
And I am able to call other methods in same way having string and integer parameter.I have gone through this but didnt get anything. URL...
View 1 Replies
Mar 24, 2010
I'm playing around with a asp.net page that's using the IScriptControl interface to pass data from the code-behind to the custom javascript object running on the browser.I'm passing a number of properties via IScriptControl.GetScriptDescriptors(), and they're all working fine, except for one.That one is a class derived from System.Collections.Generic.Dictionary<>. And even that one has been working for me, so long as the elements in the collection were scalars - ints, doubles, and strings. But when I tried to pass a member of a class, it showed up as a null object in the javascript. The class in question is marked [Serializable]. I changed it to a struct, and got the same behavior.It looks as if the serializer used in IScriptControl does a shallow copy.
View 2 Replies
Feb 22, 2010
I'm trying to bind the selections in a multiple selection SELECT, to an IList input in the controller.
<select name="users" multiple="multiple">
<option>John</option>
<option>Mary</option>
[code]...
View 2 Replies
Mar 3, 2010
I have a form which I use to create an issue. WHen you post the form, the form elements are that of a custom DTO. The DTO is then used on my POST method to create the new entity. That all works fine.
However, I want to add the functionality to add multiple issues at the same time from the same view. In effect, the user would click something like 'Report Additional Problem', and an extra set of form fields would appear (I will like use jquery for this, which I don't have an issue with). However, even with just leaving one set of form fields, the user should still be able to create just one issue. But if I habve my post method take a list or array of my DTO, it doesn't work.
Here is the post method before editing:
[Code]....
What I want to do is for this to take an array or list of NewIssueDto. I would then loop through each one in the list and create a new issue from it.
View 3 Replies
Dec 30, 2010
I have a complex object. For example a SCHOOL object that contains a collection of PERSON object. How can I use the ObjectDataSource control with a FormView and flatten the complex object? An example display would be to display the school name and comma separate the students on the page. Is this possible?
public string Id
{
get { return m_id; }
[code]...
View 1 Replies
Jan 31, 2011
My DataTable is programatically generated, and contains objects of type JobInstance in the cells.
[Code]....
When I bind this DataTable to an ASP GridView, it only displays the first column. But if I remove the "typeof(Job)" when creating the column (the line with // !!!), the GridView displays all the columns by showing the result of JobInstance.ToString() in the cells. However, I have no access to the underlying JobInstance object, only the string values that are being displayed.
I need access to the JobInstance object when displaying the GridView (for example in the OnRowDataBound), because I want to access the fields inside JobInstance for each cell to determine formatting options, and add other links in each cell.
View 1 Replies
Jun 11, 2010
I'm trying to use formview in order to do insert of a new entity object (called Customer) Customer has a reference to another entity called Address. How can I fill both of them in the same formview?
View 1 Replies
Feb 20, 2011
I want to be able to update a model and all its collections of child objects in the same view. I have been referred to these examples: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx and http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/ .
For example, I have an object Consultant, that has a collection of "WorkExperiences". All this is in an Entity Framework model. In the view, the simple properties of the Consultant object is no problem, but the collection I cannot get a textbox to show up for. I tried following the examples in the links above, but it doesn't work. The problem is, in those examples the model is just a list (not an object with a child list property). And also, the model again is an EF model. And for some reason that doesn't seem to work as in those examples.
[Code]....
This stuff with the EditorTemplate works fine in Phil Haack's sample project, which I downloaded to try, but here, with the EF model or whatever the problem is, I don't get any textbox at all. The table in the view is just there as a test, because in the table I do get the rows for WorkExperiences, whether I add an empty WorkExperience object or fill out its properties doesn't matter, the rows show up for each object. But again, no textbox...
View 2 Replies
Mar 26, 2010
I have this object in my server side:
[Code]....
Now I do this on the client side, to send a typed object to the server:
[Code]....
and actually it works. The problem is that I cannot find the way to stablish this property: "public ThingDetails[] details;"
View 7 Replies
Mar 20, 2010
designing Business Objects. What a business object class can contain ?
I have looked many sample codes and articles. Some only use properties in them. Some use private members, properties and constructoers. As more I am reading becoming more confuse.
Some sample codes that I checked were making functions in BO classes as well. what a BO class should contain and what is its purpose. Should there be functions in them as well ? If yes how they can be differentiated from Business Logic class functions.
View 5 Replies
Feb 23, 2010
I am new to OOP. Kindly guide me why making business objects is good ? how and what benefit they bring in development. As I am new to OOP if please you decidable with example in simple way will be great help to me.
View 3 Replies
Feb 2, 2010
We are using below class(TypeInterceptor) in one of our project to create the instance of business objects.
To Create any business object, we are using the below code
++++++++++
BLayer.TestBO objTestBO;
this.objTestBO = TypeInterceptor.CreateObject<BLayer.TestBO>();
+++++++++++
I think using this kind of creational pattern makes the application not scalable as the same instance will be shared among all the concurrent users.Is it correct?
Is there any better way to abstract the creation and maintaining instance of business objects
Class code:namespace Microsoft.IT.RelationshipManagement.Internal.CISF.Infrastructure
{
using System;
using System.Linq;
using System.Text;[code].....
View 5 Replies
Apr 2, 2010
I have a table in my database with a one to many relationship to another table, which has a relationship to a third table:
[Code].....
This seems to work fine. My question to you good folks: Is there a correct way to do this? I tried following the making a custom model binder per the blog link I posted above but it didn't work (there was an issue with reflection, the code expected certain properties to exist) and I needed to get something going ASAP. PS - I tried to cleanup the code to hide specific information, so beware I may have hosed something up.
View 1 Replies
May 12, 2010
Unit Testing for Business Object
View 2 Replies
Mar 25, 2011
I'm currently writing an N-Tier architected ASP.NET system with a relatively normalised SQL database backend, but I'm struggling to get my head around how lookup values should be represented in my business objects (I don't get the priviledge of using EF or ORMs). My table (as an example) could be structured like this:
CoreDataTable:
ID | Name | Favourite_Colour
---|-------|-----------------
01 | Peter | 01
02 | John | 03
03 | Mary | 05
ColoursLookup:
ID | Colour | is_active
---|--------|----------
01 | Red | 1
02 | Green | 1
03 | Blue | 1
04 | Pink | 1
05 | Black | 1
Now initially, I had created my business object to look like this:
[code]....
I'm 100% convinced that I'm (a) overthinking this, and (b) making it more complicated than it needs to be. So, is there a preferred way of doing this? Or is there an option that I've overlooked?
View 2 Replies