Hi,
I've this simple Entities from DB tables
But i want my POCO classes to be just two classes:
public class Country
{
public string ID { get; set; }
public string Name { get; set; }
public string LocalName { get; set; } // this localized
public string Region { get; set; }
public IEnumerable<City> Cities { get;...
I am working on a project where we need to fetch data from a WCF service. The service code looks up the database thru the Entity Framework. However inorder to prevent sending down EF generated classes across the wire into the proxy generated by the client we have decided to map the values from the EF classes to custom built DTO classes, ...
I see this:
public class MyGenericClass<T> where T:IComparable { }
and I have this:
public class ProductRepository : IRepository<Product> { }
How would you code something like this?
public class ProductRepository<T> where T : Product : IRepository<Product> {}
After all that, I thought I could simply make a single Repository clas...
I need to page records but I don't know the Entity's fields. Any way to OrderBy the Key (whatever it is) or simply specify some default OrderBy Lambda?
For example, I can do this with the Where Clause without knowing the Entity's properties:
var myRecords = DC.Products.Where( p => p);
This is a case where the Skip and Take require ...
I am working on my first large project that uses EF4 and have been pondering concurrency situations as I am implementing certain business scenarios. I understand that EF has built in support for optimistic concurrency by setting Concurrency Mode to Fixed on entity properties. This seems to be sufficient in most cases. Several things I...
This code returns a variable set of fields and I want to return a strongly typed <E>:
public IList<E> Get(Expression<Func<E, object>> selectLambda == null)
{
if (selectLambda == null)
selectLambda = p => p;
var partialSet = DC.CreateQuery<E>("[" + typeof(E).Name + "]");
foreach ( var record in partialSet)
{
...
I was deleting an Entity based on it's primary key, then I made my repository generic. Here's my current delete method:
public void Del(E entity) // where E : EntityObject on the class
{ if( entity != null)
DC.DeleteObject( entity);
return;
}
It's running in a MVC 2 web application. So, the users send up primary key v...
Given this code:
private ObjectQuery<E> GetEntity()
{ // Pluralization concern. Table and Type need to be consistently named.
// TODO: Don't get cute with database table names. XXX and XXXs for pluralization
return _dc.CreateQuery<E>("[" + typeof(E).Name + "s]");
}
Is there any way to determine an Entity type's plural name...
Hi,
I'm trying to implement a class in a Silverlight 4 RIA Services application that manages different ObservableCollections that are used for data binding. These ObservableCollections need to be identified by a string name and an integer classID, which I have implemented by nesting Dictionary objects in a Dictionary> object. The proble...
All entity created by EF is partial class. so it is extendable. Suppose I have entity Person like
partial class Person{FirstName, LastName, .....}
Then I want to add a compute property Name like:
partial class Person{
[DataMember]
public string Name
{
get { return String.Format("{0} {1}", this.FirstName, this.LastName); }...
I'm using EF4 with POCO and the code below is what I have to update a license. I only pasted here the section of the code that is relevant to the problem, which is adding LicenseDetails.
The problem is that for each LicenseDetail that are inserted, EF also unexpectadly adds rows to the "Item" lookup table. Why?!
The relationship of bo...
What are the possible reasons for getting this error:
"The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid."
I am using the auto-generated connection string that the EF Wizard created and added to my app.config, so I would think it should work?
...
Poco generator for EF 4 is great!
it took me a while to figure out how to use my existing classes as POCO's but i did and it works.
One thing i can't seem to still be able to figure out, is how to use the same class for 2 entities.
Seems that the POCO class has to have the same name as the Entity it is going in place of, and not ju...
I have a POCO class, mapping to a table that basically contain three primary keys as follow:
public class ContactProjectSite
{
public int ContactID { get; set; }
public int ProjectID { get; set; }
public int SiteID { get; set; }
public virtual Contact Contact { get; set; }
public virtual Proj...
How can I add an entity to the database through EF4 without attaching all of its referenced entities first?
var entity = new MyEntity() { FK_ID = 4 }; // associated entity key
using (var db = new MyEntities())
{
db.MyEntity.AddObject(entity);
db.SaveChanges();
db.AcceptAllChanges();
}
This code keeps trying to also inser...
I'm using POCO generated classes - any way that I can tweek the template so that when I remove from a child collection, the item removed is also deleted from the db ?
Or maybe in the partial class I can override something, catch an event ..?
Basically I want Order.OrderDetails.Remove(orderDetail) to remove the orderDetail from db.
I ...
I am using this query:
public IEnumerable.....{
var query = from d in Context.Documentos
where d.CodigoEquipamento == documentoDTO.CodigoEquipamento &&
d.Codigo == tipoEquipamentoDTO.Codigo
select new DocumentoDTO
{
Codigo = d.Codigo,
CodigoEquipamento = d.CodigoEqu...
Hi,
We need to implement a .NET WCF service that will be a part of a SOA solution, which means it's entities will pass through and be changed by both Java & .NET based services, and also on Desktop clients (though they will probably be .NET, but it shouldn't matter).
In order to achieve this flexibility, all objects have to be stateles...
I've seen some discussion about L2S vs EF4 on Stack Overflow back in April, when VS2010 was launched, namely:
Dump Linq-To-Sql now that Entity Framework 4.0 has been released?
Is Entity Framework worth moving to for a new small app?
Now, after 6 months, presumably people have had more interacting with EF4, so I'm curious of fresh opin...
Hi. I have a page like Order - Order lines. Order represents by some textboxes and ddls, Order lines represents by GridView.
I want to let users add order lines without save changes to database. For example: he adds 4 order lines, fill order info and then hits Save button. Only an that moment all information should be saved to DB.
When...