ADO.NET :: Set Aliases In LINQ Entities Framework?

Jul 29, 2010

i have a table with a field name called 'Firstname' and another field name called 'Lastname'. I would want to have a single column in my GridView which show Fullname and then the firstname and lastname are showed here under an alias. Also, i am binding my GridView using LINQ.So is there a way to create aliaswith LINQ and to use these with GridView ? Would love to have an hint about how i can realize this task.

View 5 Replies


Similar Messages:

Entity Framework 4 Merge Changes Between Two Entities?

Feb 8, 2011

I use the ObjectDataSource in an ASP.NET Application.

Using the ASPxGridView. When Updating it goes back to the Data Access Layer and tries to update the Entity, now as I can see while having some properites (Columns, Visible = false) when the entity arrives in the update method the visible = false columns have no values.

I don't want to show all the columns...what if I need 3 of the 30 columns? So I thought I would get the original entity from the context and merge the differences from the updated entity.

View 1 Replies

Entities Framework 4 Code First: Inheritance

Oct 11, 2010

I am currently trialing EF4 code-first. My POCO classes inherit from an Audit class that contains CreatedBy, CreatedOn, UpdatedBy, UpdatedOn. I was hoping the framework would include the Audit properties in my Action table when creating my database, however this doesn't appear to be the case. Does anyone know how to enable this without overriding the OnModelCreating() method?

Public Class Audit
Public Property CreatedOn as DateTime
End Class
Public Class Action
inherits Audit
Public Property ActionId As Int32
End Class

View 1 Replies

ADO.NET :: Differences Between Entities Framework And LINK To SQL?

Jul 29, 2010

I just want to know what are the main differences between ADO.NET Entities Framework and LINK to SQL ? It is okay to use ADO.NET EF for a simple website ? What advantages each have?

View 3 Replies

Inheritance With POCO Entities In Entity Framework 4?

Mar 12, 2010

I have a Consumer class and a BillableConsumer : Consumer class. When trying to do any operation on my "Consumers" set, I get the error message "Object mapping could not be found for Type with identity Models.BillableConsumer.

From the CSDL:

[code]....

Is this because I did not specifically add the BillableConsumer entity to the object set? How do I do that in a POCO scenario?

View 1 Replies

Entities Framework 4 Code First: Business Methods

Oct 15, 2010

Could anyone tell me where is the best place to put my business methods when using EF4 code first POCOs? Should they go in the POCO class? E.g.

public class customer
public property Id as int32
public property Name as string
public property Archived as boolean
public sub MarkAsArchived
me.Archived = true
end sub
public function EmailAllInvoices as boolean
...
end function
end class

Or should the POCO class be as clean as possible and a seperate class be used for business logic which accepts an instance of a customer POCO in the constructor to work on?

View 2 Replies

ADO.NET :: Entities Framework 4.0 Dependency Injection, WebForms?

Feb 21, 2011

I am sort of new to Entities Framework however I have successfully built a complete CMS website with the Entities Framework 4.0 in MVC 2.0 following the design patterns and examples laid out in nerddinner and MusicStore.

I am now building another application in ASP.NET webforms however would still like to flex the ORM capabilities of ADO.Net Entity Framework 4.0 however found that it seems like I am always forced to use Entity ObjectDataSource to bind to a GridView etc...

I know I might sound silly to some however I need a few pointers on creating this ASP.NET web application to use Entity Framework and use something like the design pattern of Dependency Injection etc... and still able to bind to GridViews programmatically in code behind.

I like the seperation of using a ntiers design but also would like to have full code control and not be forced to use ObjectDataSources in my aspx page.

View 3 Replies

ADO.NET :: Entities Framework Changes Detection - Refresh To Reflect New Changes?

Jul 29, 2010

I have some questions regarding the entities framework. Once you create your DataModel, if later you modify it such as removing fields adding tables it is possible for the EF to auto detect changes or you have to refresh it manually? If you have to refresh it.. how do you refresh it to reflect new changes? Also do it affect in any way the data in the database?

View 2 Replies

C# - Get Data From Entities That Inherit Others In Entity Framework 4.0?

Oct 19, 2010

Due to the way the database was designed, in my model I have a User entity. The Contact entity inherits from the user entity, and the Profile entity inherits from the Contact entity.

How can I get a list of Profiles, and, how do I create a Profile?

View 1 Replies

Storing Entity Framework Self Tracking Entities In Session

Aug 13, 2010

let us assume that I have a reusable business layer that further makes use of a data access layer that was implemented using Entity Framework 4.0. The entities returned/consumed by the business layer are self-tracking, allowing us all the goodies that come with those type of entities. I would like to be able to store the entities I work with across post backs (on order to avoid re-querying every time). Basically let us assume I have a paged GridView with 10 items in it, and something like a DetailsView to edit those items. Every time you select a new row on the grid, the details view updates with the information of the selected row. My preference would be to only query for the entities on the initial request of the page and store it in session. Then subsequently I have a list of entities that I can work with and eventually modify and send back to the business layer with all of the changes.

I really want to use session instead of view state to reduce the page payload (self tracking entities are heavy) however I really like view state for this because of the fact that when the user navigates away from the page there is no residual effect. Some of the things that worry me are: When a user navigates away from the page to another page, the entities from the previous page are still in session. I could always do something on load of a page to do housekeeping type of work. Not sure if that's good practice. I am worried about people opening browser tabs and having two views into the same page, it seems like that might pose a problem. Is this even a good approach? Seems like I am trying to have the best of all worlds, it would definitely be much easier to simply re-query on every post back for the entities and pay the 50-100ms hit of the database trip.

View 2 Replies

Entity Framework - Use Of Self-Tracking Entities In Across Multiple Posts

Dec 14, 2010

I have a model that consists of Order, OrderLine, Product.

I want to create an Order and add OrderLines (each OrderLine related to a Product). I create the Order and add new OrderLines to it. Between posts I store the Order entity in Session (or ViewState). Just so you know I have added suppport for binary serialisation which works fine.

The relationship is therefore Order > OrderLine(s) > Product(s).

You might have already guessed what the problem is - that when I SaveChanges() I get the usual 'AcceptChanges cannot continue because the object's key values conflict with another object in the ObjectStateManager.' error.

I have referred to a number of articles online but none seem to handle this case (where I have the relationship across more than two entities) e.g. [URL].

This must be a very common requirement surely? Is there anyone out there doing the same kind of thing with Entity Framework (and without using DTOs etc)?

View 2 Replies

ADO.NET :: Use SP With Linq To Entities?

Sep 25, 2010

How to use Stored Procedures with Linq to Entities? I prefer an example with input and output The videos on asp.net only show how to do this with Linq to SQL.

View 5 Replies

Sql To Linq To Entities

May 13, 2010

I have a simple join:

SELECT * FROM MessageAlerts AS A LEFT OUTER JOIN Contacts AS C ON A.ContactId = C.Id LEFT OUTER JOIN
Users AS U ON A.UserId = U.Id INNER JOIN Businesses AS B ON B.Id = C.BusinessId OR B.UserId = U.Id

how to do this : ON B.Id = C.BusinessId OR B.UserId = U.Id with linq in entity framework.

View 2 Replies

MVC :: What E Position Is For Linq To Entities 2 SQL

Jan 27, 2010

WHY are all the examples on this site linq to SQL? Did ms not themselves announce dropping support for l2SQL over a year ago? i really don't get it. Examples are great.. but really not helping me since i've gone ahead and listened to MS. And can someone at MS clarify what the position is for linq 2 SQL.. Is it supported? Recommended? What the hell.

View 7 Replies

ADO.NET :: Structure The BLL Using LINQ To Entities?

Nov 10, 2010

I am trying to learn LINQ to entities, and am working out how to best structure my BLL layer. I have generated the entity model and have created a generic repository in my DAL that returns results as IList<T>. I initially created the BLL to also return

results as IList<T>:

public IList<DAL.Customer> SelectAll()
{ [code]...

Now I am working on the aspx page, and I can create an ObjectDataSource and configure it to use my BLL, but since I am returning IList, I can't sort since I am not using a DataView. I have seen some articles on the web for converting IList to DataView, but that seems like a lot of overhead for every query.My goal is to keep a clean separation between layers without making things overly complicated. I would like to know how others have done this, or maybe a link to a good tutorial that shows how to structure all three layers.

View 8 Replies

DataSource Controls :: Best Way To Handle Inserts For Entities When Using FormViews And Entity Framework 4?

Mar 3, 2010

I am trying to get some guidance with this issue:

I have a Customer object that has two address ID fields (one for HomeAddress and one for WorkAddress)

I am loading the Address Objects by using Include="HomeAddress, WorkAddress" and then binding to the properties using the Navigation Property on the Customer Entity

Can I use just one FormView for doing the Insert/Updates and binding it to an EntityDataSource or would I have to do all the Inserting/Updating manually?

View 1 Replies

ADO.NET :: Contains() Method Not Working In Linq To Entities

Mar 8, 2011

I am building a web application in asp.Net 4.0 and entity framework. I am trying to retrieve a list of products based on a collection of id's. I first gather all the id's in a collection and then pass it to the linq query. I am trying to get a functionality similar to the IN clause in SQL. The problem seems to be with the Contains() method in the Linq to entities query. Here is my Linq code:

[Code]....

I got the above Linq to entities method from here: [URL]

View 2 Replies

Constraint On Linq To Entities Include?

Jun 22, 2010

I have a message table that self joins to itself where Message.ID == Message.Parent. So I have 1 Message with several ChildMessages. This is set up nicely with a Navigation property.

The code is currently:

var message = from m in soe.Messages.Include("ChildMessages")
where m.ID == id
&& m.IsActive
select m;
return message.FirstOrDefault();

What I really want is to only return 1 Message (that is equal to a particular ID and isActive) with all of its Active ChildMessages and I want to do it in one call to the database.

View 2 Replies

C# - Temp Table In LINQ To Entities?

Nov 4, 2010

I have a table of user ids that is huge.

I have an array of user ids that I want.

I have two tables that have a foreign user id key.

What is the best way to get this information performance wise?

Ideally in SQL the final result would be somewhat like this (null values if there is no user ID in one table but not the other):

userid table1value table2value
1 null 12
5 123 null

View 3 Replies

MVC :: DropDownListFor And Linq To Entities At Post?

Apr 14, 2010

I use the Entity Framework and Linq to Entities with MVC 2.0. When use the DropDownListFor from Html helpers to populate a dropdown that contains an ID from a foreign object, I post the form data but I canīt set the correct relation. Using the debug, I can see the ID retrieved from dropdown at my returned foreign object ID, but I think that I not use the association correctly.

View 4 Replies

C# - Linq To Entities / Create Database

Dec 15, 2010

In linqtosql you could do something like:

datacontext.CreateDatabase() to generate a database from the model in sql.

I'm wanting to do the same thing in linq to entities.

Say I have a class MyEntities which inherits from ObjectContect is there a similiar method?

View 2 Replies

ADO.NET :: Inserting Data With LINQ To Entities?

Aug 11, 2010

have already used the latest technology in a professional manner. NETBasically I have two tables related 1 to 1:the Users table and the table ProfiloPersonale is the key to the Users table that this table are ProfiloPersonale iduser and type uniqueidentifier and diagram sql server 2008 I can clearly see the report, I also did a test to insert a record in the users table ( fictional) directly from sql server and everything works.With LINQ to Entities does not work:The entities 'LEntities.Users' part of the eport 'ProfiloPersonale'.Found 'ProfiloPersonale' related to 0.Expected 1 'ProfiloPersonale'Of course what I am doing is to first create the user and then create their profile in the db, taking the id of the registered

View 1 Replies

C# - Insert A New Row Using A View With Linq To Entities?

Dec 17, 2010

I have a view on my database and I am trying to add a new record using the AddTo method but it is not working. I noticed that LinqToEntities is creating the insert statement like this

Insert into (select field1, field2 from my_view) (field1, field2) values (value1, value2)

Is it possible to make LinqToEntities create the insert statement like the one below ?

Insert into my_view (field1, field2) values (value1, value2)

View 1 Replies

ADO.NET :: Linq To Entities Update Model?

Dec 8, 2010

I am trying to update an item with entity framework but I am unable to do that;

[Code]....

it didn't give any error. it passed but when I looked at the database, nothing changed. can you provide me the right way.

View 1 Replies

ADO.NET :: LINQ To Entities - Getting The Value Of The Rows By Column?

Nov 17, 2010

All I am trying to do is query the database, then get the returned values, so that I can do some calculations. But, I don't understand how to get the values from the database row that is returned, so that I can assign it for usage.

I would like to do something where the logic goes: for the index of [1] (which is just column 1), multiply it by 2. For the index of [2] (which is just column 2), multiply it by 3.

Example below:

This does NOT work:

[Code]....

View 6 Replies







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