Entity Framework - Query Data In A Navigation Property Table?

Oct 18, 2010

I have a the following setup

m_handsets = From p In RL.App.TComEntities.tblTelephoneNumbers _
Where p.companyId = m_CompanyID _
Select p

m_handsets = DirectCast(m_handsets, ObjectQuery(Of RL.TelephoneNumbers)).Include("tblCalls")

where m_handsets is defined as Private m_handsets As IQueryable(Of RL.tblTelephoneNumbers)

which works as expected however what I want to do know is query the Navigation property (tblCalls) so I can do something like the following From p In m_handsets.tblCalls Where m_handsets.tblCalls.price > 100

I think the complexity comes here because in this instance I could have 5 tblTelephoneNumbers in m_handsets and then x amount of calls for that particular telephone number. I am interested in the tblCalls for each but I would like to filter them all for each tblTelehoneNumber.

Entity Diagram which (hopefully) should illustrate further So I currently know all the handsets that are associated with the company I am interested in. I can also see the calls loaded as a navigation property in debug mode, but I want to say is take this filter (in this example price>100 and apply it to all handsets->calls

View 1 Replies


ADVERTISEMENT

Entity Framework Returning Different Data Then DB Query?

Jan 4, 2011

I have a view on some data in my database it returns the data as I would expect, for example

Call Date To From Phone Number
20/1/2010 00:00 23:59 08923233223
20/1/2010 00:00 23:59 08923233245

However when I have added this to my Entity Model and query it I get duplicate(and unexpected) data appearing

Call Date To From Phone Number
20/1/2010 00:00 23:59 08923233223
20/1/2010 00:00 23:59 08923233223

I am simply binding a Entity Data Source to this Entity but I am left scratching my head as to why the data is being returned differently

EDIT: Interestingly this can't be the result of some strange under the hood join as the row counts match as expected. I have also put together a query myself to test with the same odd results.From o In App.Entities.v_PersonalRules Where o.companyid = CompanyID Select o. I am using Visual Studio 2010, .NET 4

EDIT: The front end code is fairly simple

<asp:EntityDataSource ID="EDS_Personal" runat="server" ConnectionString="name=Entities_NEW"
DefaultContainerName="Entities_NEW" EnableDelete="True" EnableInsert="False"
EnableUpdate="True" EntitySetName="v_PersonalRules" EntityTypeFilter="v_PersonalRules" >[code]....

View 2 Replies

.net - Entity Framework Query With More Than One Join VB?

May 10, 2012

I'm trying to use the Entity Framework to create a complex query and get stuck in the joins. After browsing some of the documentations, I cannot seem to find the correct solution, so maybe someone here can help.

I have a data structure where a family has several family members, each of which can have more than one entry in the income table (on different registration dates) and can have more than one entry in the healthconditions table.

[Code]...

View 1 Replies

VS 2010 : Entity Framework - Specify Read Only Property?

Apr 18, 2012

I'm struggling a bit with Entity Framework 4.x. Let's say I have a model called Product. It was generated from a database table. There is a field in this entity called CreatedDate. The MySQL database has a default value for the current timestamp. I don't want Entity Framework to set this field when inserting or update the table. Problem is, I can't seem to figure out how to tell EF to exclude this field from being sent back to the database, but still retain it as a field to be viewable in the application.

View 2 Replies

Asp.net - Create A Composite Property In An Entity Framework Model?

Apr 6, 2011

I have two properties ("FIRST_NAME" and "LAST_NAME") I need to access as a single property (e.g. "FULL_NAME"). Is there a way for me to add a property to my entity model that contains the combine value of FIRST_NAME and LAST_NAME?

View 1 Replies

Entity Framework Navigable Property Not Set To Instance Of Object?

Mar 21, 2012

I have the following query:

Dim queryStudent = (From p In dbContext.Residents _
Where p.people_code_id = people_id _
Where p.year = year _

[code].....

View 2 Replies

.net - List Of Scalar Values From Entity Framework Query?

Dec 22, 2011

I have Customers table in a database. I'd like to create List of CustomerNames using entity framework 4.1. How can I do that in Visual Basic?

Dim customerNames = (From c In _context.Customers
Select New With {c.CustomerName}).ToList()

brings a list of anonymous objects.

View 1 Replies

C# - SQL / Entity Framework Error On Date Range Query

Apr 29, 2012

I'm receiving an error when trying to query a range of dates from a MS SQL DB in MVC Entity Framework. Unable to cast the type 'System.Boolean' to type 'System.Data.SqlTypes.SqlBoolean'. LINQ to Entities only supports casting Entity Data Model primitive types. This is our query:

[Code]...

View 1 Replies

Entity Framework Query Returns Same Row Multiple Times

Aug 31, 2011

This is my first time using the Entity Framework and I'm getting some confusing results. I know a particular table contains 3 distinct rows when I run this SQL query:
SELECT * FROM mytable WHERE service_month = 201012

When I run this query against the framework however, I get 3 rows, but they are all copies of the first row (VB syntax).
Dim temp = _context.mytable.Where(Function(x) x.service_month = 201012)
Did I set up something incorrectly? This is how I'd do it with LINQ to SQL.

View 1 Replies

Asp.net - Update A Child Table In Entity Framework

Mar 7, 2012

I have 2 tables in my DB: "Competitions" and "CompetitionAnswers". Each competition will always have 3 answers. I want to be able to edit the Competition and CompetitionAnswers for the same view. I have managed to get the view to work by using editor templates So this is my editor template:

[Code]...

View 1 Replies

TextBox.Text To Sql Table Using Entity Framework

Jun 8, 2012

How would I go about getting text from several textboxes and adding them to a new row in a sql table in their respective columns? For instance, I have textbox id's and sql column names of:

[Code]...

The program will be storing the values in a multidimensional array to simulate data from multiple customers. I want each row in the array to be assigned to a new row in the sql table upon the click of a button. I've got everything setup but the writing of the all the textbox values into their own rows in the database.

View 2 Replies

Entity Framework 4.2 Table Per Hierarchy Group By Discriminator?

Dec 7, 2011

I am working on a project using an EF 4.2 code first model. This model contains a TPH inheritance structure for products. I need to group the polymorphic results of this inheritance model on the discriminator and am running into some issues.

The entity framework does not expose the discriminator to complete this grouping. My first question is can I get direct access to this discriminator? My reading and experience is telling me no, so I came up with this solution that sort of works. It is not performing well and I am not happy with how it will need to be maintained.

My classes look something like this (simplified):

Public MustInherit Class Product
<key()>
Public Property ProductID as integer

[Code].....

Also, this can give me easy access to shared properties (Name) but now I don't have many options to cast these into their real type, maybe a select case around TypeName.

View 1 Replies

In Entity Framework, We Can Use Model First, DB First, Code First But How Can We Create Table Programmatically?

Jun 9, 2012

In entity framework we can use 3 approaches model first , code first , database first but each one of them needs manual hand touch(means creating database or create model or write the POCO class codes or entity class codes) before proceeding to the next step ( using EF in context ).What if I want to create database and tables and table relationships programatically and still want to have to features of EntityFramework 4.3.

To be more specific ,from this example http://support.microsoft.com/kb/307283 we can create database , tables and everything using SQL command but we can't have the advantages of entity framework. So if we want to have that what should we do? To give the ability to create dynamic table fields those steps will not be sufficient. In all 3 steps database , table and table columns are fixed. There is no way that a user can create new tables or columns dynamically. http:[url].... in this post , it shows how to create manual db, tables and etc using SQL but it is based on ADO.NET but I want Entity Manager to do that.

View 3 Replies

C# - Are Microsoft Entity Framework And ADO.NET Entity Framework (.edmx) The Same

May 13, 2010

c# - Are Microsoft Entity Framework and ADO.NET Entity Framework (.edmx) the same?

View 7 Replies

Entity Data Framework 101

Sep 28, 2011

I am used to using datasets for my projects in terms of data access. I now set myself an easy app to work on in order to learn the entity data framework and how to retrieve & manipulate data.Can anyone guide me through on where to start, what are the advantages of this model, In what scenarios should I choose to use entity framework and what are the things (basis) I should now before starting.My datasets are working fine too. Are there any reasons for me not to stick with that way of accessing data? Or is this something to consider depending on the users of the website (for speed purposes etc.)

View 3 Replies

Entity Framework 4.1 Data Real Time

Mar 9, 2012

I'm using EF version 4.1, and would like to have the data from the database in realtime, i.e. if you open the application it detects if there is new data in the database, and update the above it! is It possible to do this? I am using EF 4.1 code first time

View 1 Replies

Entity Framework Does Not Save Data - Only For Reading?

Mar 29, 2009

I am having trouble getting the new Entity Framework's objects and classes to store data in my database. I have tried basically everything I can think of, asked for various forums with no success, and I am starting to wonder if the new EF is merely for reading data and not saving it. Now, I decided to make atest Console application to make a single record in the database. The code is quite simple:

Sub
Main()
Dim ent As New MyModelEntities()

[code].....

View 4 Replies

WCF Window - Entity Framework Data Compression

Feb 3, 2012

I have a WCF Windows service that provides data to 250+ PDAs via compressed datasets and was looking to redevelop both the service and the mobile application to use Entity Framework 4.x models. In order to keep performance acceptable when sending/receiving data on the PDA I need to keep the data size as small as possible and was wondering if its possible to compress a IEnumerable from the WCF windows service? From previous experience with the datasets I got a 80%+/- compression rate and even decompressing the data on the PDA achieved an overal 50% performance importment so retaining similar levels of performance is critical. Could I use a binary serializer and then compress the stream?

View 1 Replies

Asp.net - List Of Select Data In Entity Framework (linq)?

May 4, 2012

This is my function:

Public Function GetAllEmployee() As List(Of Employees)
Return DB.Employees.Select(Function(q) New With {q.EmployeeID, q.LastName,q.FirstName}).ToList()
End Function

I'm getting an error:

Value of type System.Collections.Generic.List(Of <anonymous type>) cannot be converted to System.Collections.Generic.List(Of NorthwindModel.Employees).

View 1 Replies

C# - Entity Framework/LINQ To SQL Data Binding Use Reflection?

Apr 20, 2009

I'm taking a peek at both the Entity Framework and LINQ to SQL, and while I like the systems (and of course the LINQ integration) I'm a little skeptical on the data-binding aspect. I've taken query results and inspected them, and they don't appear to implement the standard .NET list-binding interfaces (IBindingList, and more importantly ITypedList), leading me to believe that binding them to a grid (or anything else) is going to use reflection to get/set my entity properties. This seems like a comparatively expensive operation, especially when all of the code is generated anyway and could implement the interfaces. Is reflection used to get/set the value of the properties?

Edit: I'm actually concentrating on whether or not ITypedList is implemented somewhere along the way, as that's what has the capability to provide an explicit mechanism for defining and interacting with properties without resorting to reflection. While I didn't have a LINQ to SQL project up,I did inspect a simple Entity Framework entity query result, and it did not appear to implement ITypedList.

Edit 2: After accepting Marc's answer, I thought it might be helpful for others if I posted some simple code I used to seamlessly implement his solution. I put the following in the static constructor for my class:

public static ContextName()
{
foreach(Type type in System.Reflection.Assembly.GetExecutingAssembly()[code]....

While this is for LINQ to SQL, I'm sure an equivalent version could be written for the Entity Framework. This will scan the assembly for any types with the Table attribute and add a custom provider for each of them.

View 3 Replies

.net - ADO.net Entity Framework - Update Only Certain Properties On A Detached Entity

Jul 22, 2009

I want to update an entity without loading the entity from the database first. I've accomplished this but only by knowing all of the entities properties and then using the "attachto" method. My issues is i don't want my app to need to remember all of the properties. Example:

[Code]....

View 3 Replies

.NET Sample Entity Framework 4.2 Code First Entity Splitting?

Dec 14, 2011

Entity Splitting: one class, two or more tables.Here is how it is done in C#, but I need to get it working in vb.net.One more thing: the class name and table columns do not match, so I have to be able to map that out, too.I have to get this to work this way because the place I'm working at right now is a vb.net only shop and the database schema is fubar, but they have so much (millions) of lines of code done directly against the database in both asp classic, vb.net, AND asp.net webforms that changing the schema right now is not realistically possible.

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Post>()
.Map(m =>

[code]....

View 1 Replies

Asp.net - Using ExecuteQuery() With Entity Framework, Entity Class

Jan 16, 2011

I am trying to jump from ASP Classic to asp.net. I have followed tutorials to get Entity Framework and LINQ to connect to my test database, but I am having difficulties figuring out ExecuteQuery(). I believe the problem is that I need an "entity class" for my database, but I can't figure out how to do it. Here is my simple code:

Dim db as New TestModel.TestEntity
Dim results AS IEnumerable(OF ???) = db.ExecuteQuery(Of ???)("Select * from Table1")

From the microsoft example site, they use an entity class called Customers, but I don't understand what that means.

View 1 Replies

Entity Data Model And Insert With Identity Property

May 6, 2010

in a new project I thought I would try to integrate the new Entity Model Framework, but am having some issues/problems and would like to know if there is a solution or workaround that will let me insert a record into a table that has an identity property.At first I thougth it might simply recofnize the storedprocs that I have for insert/update/delte actions, and was a bit discapointed when generating the model ignored all my stored procs. So I thought wll heck maybe it just generates a nice insert method for me. Lets see.So I referenced my model and found that for the table (entity) there was an insert action (method) that had been generated, however what i found is that it explicitly added the primarly key field - which was based on an identity property and will not accept an explicit insert value.So I guess 2 questions

1. How do we work with identity properties

2. How can we take advantage of the performance and securtiy advantages that stored procs offer with SQL server?

View 1 Replies

How To Bind Entity Data Source To Results Of Query

Oct 10, 2010

I have a query that will go away an and find data
Dim HSNs As String = String.Join(",", ListOfHSNs.Cast(Of String)().ToArray())
Dim query As String = "SELECT VALUE O FROM v_BillData AS O WHERE O.HSNumber IN {'" & HSNs & "'}"
Dim hs As New ObjectQuery(Of v_BillData)(query, CType(Session("ObjectCon"), ObjectContext))
What I now wish to do is to use the results of this query to databind to a EntityDataSource?

View 1 Replies

Fetch Data From Table Without Mapping It To Entity Model?

May 22, 2012

I am working on a silverlight project in which i am using the entity data model. I have a consol application in the same solution through which i am creating the database table at runtime. Now when i moves to silverlight page i need to Communicate (load
data from newly created tables).But problem is that without updating the model how i will able to communicate with that table at runtime using entity framework model.

View 1 Replies

Entity Framework - C# Or .Net?

Feb 18, 2010

My company is tossing around the idea of using the Entity Framework when it comes out with .NET 4. We are currently a VB.NET shop, but have some interest in switching to C#.Is there any major arguments for or against such a move?Does EF with C# hold any advantages in performance, coding ease, etc over VB.NET?

View 10 Replies

Add A Many-To-Many Relation In Entity Framework?

Apr 17, 2009

I am a newbie. I have been able to Add new entities where there is a One-To-Many Relation. I am having a problem (don't Know how to do it) adding a new Entity when the relation is using Many-To-Many. In my EDM I have:

[Code]....

View 1 Replies

ADO.NET Entity Framework Tools?

Apr 16, 2011

I downloaded the VB 2010 Express software, the total files that we included in the download was 15, but it only loaded up 12 of these files. The following downloads did not get loaded as follows:MS Visual Studio 2010 ADO.NET Entity Framework Tools

MS HelpViewe 1.0 x64

I tried reinstalling the downloads that did not using the VB Express 2010 setup, but they do no appear on the list of downloads, only the SP1 for MS SQL Server 2008 Express Server (x64).Do I require the downloads that did not load.

View 2 Replies

Asp.net Mvc - Entity Framework With Database?

Apr 21, 2012

Here are the entities that i have...

Public Class Account
Public Property AccountId As integer
Public Property AccountDescription As String
Public Property Transactions As List(Of Transaction)
End Class

[Code]...

i would like to make it suc that when i do "db.Account.find(1)" for example it also loads in the list of all transactions which have the coresponding AccountId. I'm not too sure what type of relationship this is?? anyway, right now i can do

Dim acct As Account = db.Account.Find(1) acct.Transactions = from ts in db.transactions select ts where ts.AccountId = acct.accountid but i know this is not the correct way, there must be a way to map this out so that entity can just load everything in one shot right?

View 1 Replies







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