entity-framework-4

WCF Dataservice - modify object before returning results?

柔情痞子 提交于 2019-12-06 02:20:49
I am using WCF data services and I have a few fields/properties that I want to "blank out" (set value to empty string or null) before sending back to client. For example: User table has password column which I do not want to pass the value to the client. This is one example, there are other such columns in the app that the value should be excluded for security/privacy reasons. Sorry for such a basic question, I'm new to WCF dataservices and have not found any promising leads yet. I've tried QueryInterceptors but no luck. Can someone point me in the right direction? Thanks IMO this is out of

How can I add an Image type to an EF4 Code First Entity?

我只是一个虾纸丫 提交于 2019-12-06 01:52:21
问题 How can I add an Image type to an EF4 Code First Entity? I need to add a column for thumbnail images. public Image Thumbnail { get; set; } Thanks! 回答1: Images are represented as binary in EF 4 http://thedatafarm.com/blog/data-access/sql-server-2008-data-types-and-entity-framework-4/ You will need to do something like this public Binary Thumbnail {get; set} Then convert the image to binary This reference will help you with the image to binary conversion http://www.dotnetspider.com/resources

AD0.NET Entity Framework 4.0 or Linq-to-SQL

风格不统一 提交于 2019-12-06 01:42:42
I am developing a application with asp.net 4.0. My site will be a heavy like more then hundreds of user will be online at a time and lots of content will be there. I have checked both ado.net entity framework 4.0 and Linq-To-SQL with Microsoft.NET Framework 4.0 both are having great improvement over there. I am confused that which one i should use. Performance is one key aspect of my application I don't want to degrade performance of my application via making a bad choice. Could any one will help me on this? Any link or any suggestion will be appreciated. Thanks in advance for any tip. Google

Generating Entity Keys

谁说我不能喝 提交于 2019-12-06 01:41:36
I have run into my first dissapointment with Entity Framework 4. It turns out that SQL CE, when used with EF4, does not support autogenerated primary keys . I get a System.Data.UpdateException from OnjectContext.SaveChanges() with this message: Server-generated keys and server-generated values are not supported by SQL Server Compact. So, now I have to manually generate keys for my entities. Assuming I want to use auto-incremented integer keys, what is the best way to go about generating and keeping track of the keys when using Entity Framework? Thanks for your help. At the bottom of the link

Convert Int32 to Oracle number(5) with EF4

只愿长相守 提交于 2019-12-06 00:43:41
问题 I am using EF 4 (database first, model fully generated from it) with an oracle 10g database and I have a problem with one field. My field is defined as a NUMBER(5) in my database. In my model, EF has defined it as a short . My problem is that i have some values that are greater than 32,767 (max of a short) I found this post : Entity Framework generates short instead of int. I follow the instruction and it works, my model contain now Int32 values. But I have a new problem : Error 2019: Member

Entity Framework 4 - How to cap the number of child elements from another table (connected via a foreign key)

与世无争的帅哥 提交于 2019-12-06 00:24:12
I have two data models Blog and Post . BlogId is a foreign key on the Post table public class Blog { public int ID { get; set; } public string Title { get; set; } public virtual ICollection<Post> Posts { get; set; } ... } public class Post { public int ID { get; set; } public virtual int BlogId { get; set; } public string Title { get; set; } ... } Now this works fine and my Repository is happy and pulls everything as expected from DB. My question is - Is there a way to limit the number of Posts that get retrieved. Perhaps some LINQ magic? Here is what my current method in the repository looks

Possible to use the Repository Pattern + Stored Procedures ? Should / can they return IQueryable?

▼魔方 西西 提交于 2019-12-06 00:17:16
I'm a big fan of using the Repository pattern to return IQueryable<T> objects. I then let my services layer determine what does what (eg. filter by XXX, order by YYY, project into ABCD, etc). But I've got some hardcore DB stuff, so I've got it all wrapped up into a Stored Procedure . Works fine. I know EF can execute stored procs .. but I'm not sure how this fits into a Repository Pattern data layer. Does anyone have any examples / suggestions ? Do i let the repository method execute the stored procedure, and then i return the result (eg. ICollection<Foo> as AsQueryable .. so the service layer

Sql Exception With .net 4 & EF

ぃ、小莉子 提交于 2019-12-05 23:07:37
问题 we are using .net 4 MVC2 with EF & Sql Server 2005. For some requests, and it happens rarely, and only when we are doing search which is implemented with classes mapped to stored procedures performing full text search, we get the exception: [SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2030802 System.Data

How to access 'Results', 'Messages', and 'Return Value' of a Stored Procedure using Entity Framework 4?

断了今生、忘了曾经 提交于 2019-12-05 22:26:27
问题 QUESTION How do I access the 'Results', 'Messages', and 'Return Value' of a Stored Procedure using Entity Framework 4.4 and C# 4.0? Below is the Stored Procedure that takes three parameters. One way or another when I run the Store Procedure I should, I hope, be able to access all three values for 'Results', 'Messages', and 'Return Value'. Can someone help me figure out how to do that with EF? Using the code that is generated out of EF all I seem to be able to access is the 'Results' of the

Populate a dropdown list from db

独自空忆成欢 提交于 2019-12-05 21:11:47
I have an mvc 3 application with 2 tables in my entity framework. PurchaseTable which was PurchaseID,PurchaseDate & ProductID I have another table called Product which contains ProductID and ProductName. creating a new view to insert a new purchase how do I change the textbox in the view for ProductID to be a dropdown bound by the ProductName in the Product table? Create a ViewModel: public class CreatePurchaseViewModel { public Purchase Purchase { get; set; } public IEnumerable<SelectListItem> Products { get; set; } public int SelectedProductId { get; set; } } Setup the View with the