EF - Entity Sql Contains Clausule With String?
Apr 24, 2010
I have one question about EF. If I understand correctly EF does not support Contains. I try to achieve this: I have column(nvarchar) with this: for ex.row1. 1;3;4;5,row2. 3;4;6 row3.7;8;16 etc.I have list(of string) with 1,6. My goal is to get row1 and row2 in result set.I try with linq to entity and with linq to sql but i can't get this right.
View 1 Replies
ADVERTISEMENT
Jul 27, 2011
I am trying to build a survey engine from an existing database design which is like this.
[Code]...
The line Order By Key.RecordOrder throws a null reference exception and I can understand why. Can someone advise on how to resolve this by just modifying this one query? I am fairly new to LINQ and the necessity to write this project
[Code]...
View 1 Replies
Mar 2, 2010
I am wanting to create a Where statement within my Linq statement, but have hit a bit of a stumbling block.I would like to split a string value, and then search using each array item in the Where clause.In my normal Sql statement I would simply loop through the string array, and build up there Where clause then either pass this to a stored procedure, or just execute the sql string. But am not sure how to do this with Linq to Entity? ( From o In db.TableName Where o.Field LIKE Stringvalue Select o ).ToList()
View 5 Replies
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
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
Nov 9, 2011
Given a string of categories, I need to split the string and insert each separate item as a new record using EF.The following does not work since string cannot be converted to Tag:
Dim s = "Books, Novels, Magazines"
s.Split(", ").ToList.ForEach(Function(x) _rdsqlconn.Tags.Add(x))
How can i split the string and insert each as a new tag record?
View 1 Replies
Sep 21, 2011
I've been getting this error when I try and use my model container:
No connection string named 'PFModelContainer' could be found in the application config file.
I have my edmx file in a separate project. I checked the app.config file and my model was there, and I also put it in my main project app.config file. Still doesn't work. Here's the connection string:
<connectionStrings>
<add name="PFModelContainer"
connectionString="metadata=res://*/PFModel.csdl|res:
[Code].....
View 2 Replies
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
Feb 11, 2011
I am trying to create a generic typed class, but am running into a problem. Here is my basic class definition:
public class QueueObject<T> where T : System.ServiceModel.DomainServices.Client.Entity
{
public string LoadingMessage { get; set; }
public System.ServiceModel.DomainServices.Client.EntityQuery<T> Query { get; set; }
}
I am trying to add instances of this class to a queue
private Queue<QueueObject<Entity>> _queue;
this._queue.Enqueue(new QueueObject<MyEntity> {Query = MyContext.GetMyEntitiesQuery(), LoadingMessage = "Loading some stuff"});
This doesn't work. I get an error saying that QueueObject cannont be converted to QueueObject. I don't understand because MyEntity inherits from Entity.
Public Class QueueObject(Of T As System.ServiceModel.DomainServices.Client.Entity)
Public Property LoadingMessage As String
Public Property Query As System.ServiceModel.DomainServices.Client.EntityQuery(Of T)
End Class
[code]....
View 2 Replies
Sep 3, 2011
I understand the possibilities for encrypting a connection string in .net v4. I have a win forms application that will be used by multiple people on different machines. I understand that I need to protect the connection string at time of the app being first run on the target machine. However I am concerned that for a period of time my connection string will be unencrypted. I am looking for advice in how to deploy my app with the connection string already encrypted or encrypted during installation. encrypting the connection string in a secure way?
View 1 Replies
May 13, 2010
c# - Are Microsoft Entity Framework and ADO.NET Entity Framework (.edmx) the same?
View 7 Replies
Mar 9, 2010
in my database there are 3 tables
CustomerType
CusID
EventType
EventTypeID
CustomerEventType
CusID
[Code]...
View 1 Replies
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
May 13, 2009
I am trying to insert a record into a table using Linq but get the dreaded Cannot add an entity with a key that is already in use error 'If the same data exists for the same patient in a record less that 21 days old then drop it
[Code]....
View 3 Replies
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
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
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
May 23, 2011
We have a CRM which contains a memebr entity as the most important entity in the system. The thing is that it has too many attribute in it which makes it unnormalized. here are the attributes:
[MEMBER ID]
,[FIRST NAME]
,[LAST NAME],[TITLE],[ADDRESS 1],[ADDRESS 2]
,[ADDRESS 3],[POST CODE],[TELEPHONE HOME]
[code]....
View 2 Replies
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
Feb 28, 2012
I'm trying to learn EF in visual basic. I'm struggling with finding any easy to understand simple tutorial of how to do inner joins.
This is the SQL that i'm trying to replicate in EF:
SELECT Quote.LockedDateTime, IncommingQuoteStatus.StatusDesc, Users.FirstName
+ ' ' + Users.LastName AS UserName
FROM Quote
[Code].....
View 1 Replies
Dec 23, 2009
I have a 'user' table, a 'phone number' table and a 'user to phone number map' table. The phone number table stores only unique phone numbers. This way I can take a look at a phone number and see who is using it easily. It is also easy to check if a phone number exists when the user is edited. The question is how I should be checking to see if the phone number should be added to the map. I could loop over the loaded mapped users and check each id. There must be a method that I can use to check like EdmUser.phone_number_map.contains(PhoneNumber). However I cant find anything like this.
View 1 Replies
Jun 1, 2009
If I a many-to-many relationship between Users and Roles and I have an instance of a User entity and several Role Ids can I insert a relationship between the two types of entities without having any other Role data and without doing a select on the Roles first? Update:
I might not have been clear enough. I don't have an instance of a Role, only the role id. Is it possible to create the relationship between User and Role without filling a Role object from the database first?
View 2 Replies
Apr 21, 2011
I have an Entity (Extensions) with a number of properties (e.g. id, extension, prefix) and a few navigation properties (phones_departments, phones_buildings) - they show up in the order they display in the EDMX...but what if I want them to display in a different order
View 1 Replies
Feb 8, 2011
I have some basic expirience in Visual Basic and programming Windows Forms programs. I know now that forms programs are no longer updated by Microsoft and that WPF is the way to go. No to mention the slicker interface you can create. I've also noticed that passing SQL strings to a database is no longer the standard either. It's either Entity Framwork or Linq.
So I am going for a fresh approach. I need to develop a program that will access a sql database and be accessed by about 10 concurrent users within the office. What's the best approach in general? Linq or Entity Framework? Also, could you recommend a book or two for someone who is new to WPF and Entity Framework? I do have some programming expirience, just none with WPF or the new ways of ADO.net 4.
View 4 Replies
Nov 3, 2010
I'm currently testing the entity framework 4 for a simple app I wish to build.
how do you save and cancel changes on a record basis? Using the save changes method on the context persists all the changes to the database.
View 3 Replies
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
Apr 27, 2010
At first I was using this as an extension method to update my detached entities...
Public Sub AttachUpdated(ByVal obj As ObjectContext, ByVal objectDetached As EntityObject)
If objectDetached.EntityState = EntityState.Detached Then
Dim original As Object = Nothing
[code]....
Everything has been working great until I had to update non-scalar properties. Correct me if I am wrong but that is because "ApplyCurrentValues" only supports scalars. To get around this I was just saving the FK_ID field instead of the entity object relation. Now I am faced with a many to many relationship so its not that simple. I would like to do something like this...
Dim Resource = RelatedResource.GetByID(item.Value)
Condition.RelatedResources.Add(Resource)
But when I call SaveChanges the added Resources aren't saved. I started to play around with self-tracking entities but it seems they cannot be serialized to ViewState and this is a requirement for me.how to either save my many to many relationships or serialize self-tracking entities?
View 1 Replies
Jun 12, 2010
In my project I have it set up so that all the tables in the DB has the property "id" and then I have the entity objects inherit from the EntityBase class using a repository pattern. I then set the inheritance modifier for "id" property in the dbml file o/r designer to "overrides"
Public MustInherit Class EntityBase
MustOverride Property id() As Integer
End Class
Public MustInherit Class RepositoryBase(Of T As EntityBase)
[Code]...
however produces the error "Class member EntityBase.id is unmapped" when i use VS 2010 using the 4.0 framework but I never received that error with the old one.
View 1 Replies
Jul 7, 2011
I need to make a if-else statement in the query meaning I only want to add the OpenAmount to ExpectedAmount if the type = Cash, the problem is that it only gives me the cash row not the other row.
[Code]...
View 1 Replies
May 14, 2012
I'm working on a project that was built using ADO.NET (raw sql) and Active Record pattern. I am slowly moving it away from ADO.NET to Entity Framework Code First 4.3.Here is an example of the pattern. The interface is a static Load and an instance Save (and Delete -- not shown).
Public Class Part
Public Property Id as Integer
Public Shared Function Load(_id As Integer) As Part
[code].....
View 1 Replies