<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.dotnetzone.gr:443/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ADO.NET</title><link>https://www.dotnetzone.gr:443/cs/forums/78/ShowForum.aspx</link><description>Θέματα σχετικά με την προσπέλαση δεδομένων μέσω του ADO.NET και του System.Data namespace</description><dc:language>el</dc:language><generator>CommunityServer 2.1 SP3 (Build: 20423.1)</generator><item><title>Απ: Generic Entity Framework 4.0 Base Repository</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/59439.aspx</link><pubDate>Thu, 15 Jul 2010 18:02:25 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:59439</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/59439.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=78&amp;PostID=59439</wfw:commentRss><description>&lt;P&gt;Elementary my dear Watson. Η GetProperties σου επιστρέφει ένα array από PropertyInfo, όχι από ObjectQuery&amp;lt;T&amp;gt;. Πρέπει να βάλεις ένα Where( prop =&amp;gt; prop.PropertyType == typeof(ObjectQuery&amp;lt;T&amp;gt;) και φυσικά να βάλεις και το κατάλληλο Select. &lt;/P&gt;
&lt;P&gt;Οπότε το one-liner γίνεται&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:black;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;objectContext.GetType().GetProperties().Where(prop =&amp;gt; prop.PropertyType == &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;typeof&lt;/SPAN&gt;(ObjectQuery&amp;lt;T&amp;gt;)).Select(prop =&amp;gt; (ObjectQuery&amp;lt;T&amp;gt;) prop.GetValue(objectContext,&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;null&lt;/SPAN&gt;))&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;ή σε LINQ syntax&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:black;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;var queries=from prop &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;in&lt;/SPAN&gt; objectContext.GetType().GetProperties()
                 where prop.PropertyType == &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;typeof&lt;/SPAN&gt;(ObjectQuery&amp;lt;T&amp;gt;)
                 select (ObjectQuery&amp;lt;T&amp;gt;) prop.GetValue(objectContext,&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;null&lt;/SPAN&gt;);
&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;return&lt;/SPAN&gt; queries.FirstOrDefault();&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:black;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;&lt;FONT size=2 face=Tahoma&gt;Και μετά μου λες για γκοφρέτες ...&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/PRE&gt;</description></item><item><title>Απ: Generic Entity Framework 4.0 Base Repository</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/59438.aspx</link><pubDate>Thu, 15 Jul 2010 08:15:29 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:59438</guid><dc:creator>Markos</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/59438.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=78&amp;PostID=59438</wfw:commentRss><description>&lt;P&gt;Η GetQuery() στο RepositoryWebAppv2.Model σου επιστρέφει ένα IQueryable γιατί καλείς την &lt;A href="http://msdn.microsoft.com/en-us/library/dd382944.aspx"&gt;CreateObjectSet&lt;/A&gt;&amp;lt;TEntity&amp;gt;(). Στο extension, που δημιουργείται το IQueryable ή μήπως μου διαφεύγει κάτι;&lt;/P&gt;</description></item><item><title>Generic Entity Framework 4.0 Base Repository</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/59435.aspx</link><pubDate>Thu, 15 Jul 2010 07:22:53 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:59435</guid><dc:creator>George J. Capnias</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/59435.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=78&amp;PostID=59435</wfw:commentRss><description>&lt;P&gt;Διάβαζα χτες μία &lt;A href="http://weblogs.asp.net/fredriknormen/archive/2010/07/10/what-is-forkcan-com-do-you-have-what-it-takes-to-share-your-code.aspx"&gt;δημοσίευση&lt;/A&gt; στο blog του Fredrik Normén για την τελευταία δημιουργία του, το &lt;A href="http://www.forkcan.com/"&gt;ForkCan.com&lt;/A&gt;. Ωραία ιδέα, παρεπιπτόντως. Κοιτώντας μέσα στον κώδικα που είναι στο site, είδα &lt;A href="http://www.forkcan.com/viewcode/166/Generic-Entity-Framework-40-Base-Repository"&gt;{1}&lt;/A&gt;, &lt;A href="http://www.forkcan.com/viewcode/180/Generic-Entity-Framework-40-Base-Repository-with-Paging"&gt;{2}&lt;/A&gt; implementations για Generic Entity Framework 4.0 Base Repository.&lt;/P&gt;
&lt;P&gt;Αν και μοιάζουν αρκετά, και ξεκινούν από παρόμοιο Interface, μου "ξίνισαν" μιας και το Repository pattern "&lt;EM&gt;θα έπρεπε&lt;/EM&gt;" να είναι συνδυασμένο με το ένα "Unit of Work" pattern. Οπότε ξεκίνησα να γράφω στο Notepad...&lt;/P&gt;
&lt;P&gt;
&lt;TABLE style="BORDER-BOTTOM:#e5e5e5 1px solid;BORDER-LEFT:#e5e5e5 1px solid;BACKGROUND-COLOR:#f2f2f2;BORDER-TOP:#e5e5e5 1px solid;BORDER-RIGHT:#e5e5e5 1px solid;" border=0 cellSpacing=0 cellPadding=0 width="100%"&gt;

&lt;TR style="LINE-HEIGHT:normal;VERTICAL-ALIGN:top;"&gt;
&lt;TD style="TEXT-ALIGN:right;WIDTH:40px;"&gt;&lt;PRE style="PADDING-BOTTOM:2px;MARGIN:0px;PADDING-LEFT:2px;PADDING-RIGHT:2px;FONT-FAMILY:courier new;COLOR:gray;FONT-SIZE:11px;BORDER-RIGHT:#e7e7e7 1px solid;PADDING-TOP:2px;"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 &lt;/PRE&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;PRE style="PADDING-BOTTOM:2px;MARGIN:0px;PADDING-LEFT:8px;PADDING-RIGHT:2px;PADDING-TOP:2px;"&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:black;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;namespace&lt;/SPAN&gt; RepositoryWebAppv2.Model
{
    &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;interface&lt;/SPAN&gt; IRepository&amp;lt;TEntity, TContext&amp;gt;
        where TEntity : &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;class&lt;/SPAN&gt;
        where TContext : &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;class&lt;/SPAN&gt;
    {
        IQueryable&amp;lt;TEntity&amp;gt; GetQuery();
        IList&amp;lt;TEntity&amp;gt; FetchAll();
        IList&amp;lt;TEntity&amp;gt; Fetch(Expression&amp;lt;Func&amp;lt;TEntity, &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;bool&lt;/SPAN&gt;&amp;gt;&amp;gt; where);
        TEntity FetchSingle(Expression&amp;lt;Func&amp;lt;TEntity, &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;bool&lt;/SPAN&gt;&amp;gt;&amp;gt; where);
        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;int&lt;/SPAN&gt; Create(TEntity entity);
        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;void&lt;/SPAN&gt; Update(TEntity entity);
        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;void&lt;/SPAN&gt; Delete(TEntity entity);
    }
}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;Μετά είπα να "πρωτοτυπήσω" και να κάνω ένα abstract class:&lt;/P&gt;
&lt;P&gt;
&lt;TABLE style="BORDER-BOTTOM:#e5e5e5 1px solid;BORDER-LEFT:#e5e5e5 1px solid;BACKGROUND-COLOR:#f2f2f2;BORDER-TOP:#e5e5e5 1px solid;BORDER-RIGHT:#e5e5e5 1px solid;" border=0 cellSpacing=0 cellPadding=0 width="100%"&gt;

&lt;TR style="LINE-HEIGHT:normal;VERTICAL-ALIGN:top;"&gt;
&lt;TD style="TEXT-ALIGN:right;WIDTH:40px;"&gt;&lt;PRE style="PADDING-BOTTOM:2px;MARGIN:0px;PADDING-LEFT:2px;PADDING-RIGHT:2px;FONT-FAMILY:courier new;COLOR:gray;FONT-SIZE:11px;BORDER-RIGHT:#e7e7e7 1px solid;PADDING-TOP:2px;"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 &lt;/PRE&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;PRE style="PADDING-BOTTOM:2px;MARGIN:0px;PADDING-LEFT:8px;PADDING-RIGHT:2px;PADDING-TOP:2px;"&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:black;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;namespace&lt;/SPAN&gt; RepositoryWebAppv2.Model
{
    [DataObject]
    &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;abstract&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;class&lt;/SPAN&gt; Repository&amp;lt;TEntity, TContext&amp;gt; : IRepository&amp;lt;TEntity, TEntity&amp;gt;
        where TEntity : EntityObject, &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;new&lt;/SPAN&gt;()
        where TContext : ObjectContext, &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;new&lt;/SPAN&gt;()
    {
        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;private&lt;/SPAN&gt; TContext _ObjectContext;

        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; Repository()
        {
            _ObjectContext &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:red;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;new&lt;/SPAN&gt; TContext();
        }

        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; Repository(TContext objectContext)
        {
            &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;if&lt;/SPAN&gt; (objectContext == &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;null&lt;/SPAN&gt;)
                &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;throw&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;new&lt;/SPAN&gt; ArgumentNullException(&lt;SPAN style="BACKGROUND-COLOR:#e4e4e4;FONT-FAMILY:Courier New;COLOR:#666666;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;"objectContext"&lt;/SPAN&gt;);

            _ObjectContext &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:red;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;=&lt;/SPAN&gt; objectContext;
        }

        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;#region&lt;/SPAN&gt; ' IRepository&amp;lt;TEntity,TEntity&amp;gt; Members '

        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; IQueryable&amp;lt;TEntity&amp;gt; GetQuery()
        {
            &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;return&lt;/SPAN&gt; _ObjectContext.CreateObjectSet&amp;lt;TEntity&amp;gt;();
        }

        [DataObjectMethod(DataObjectMethodType.Select, &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;true&lt;/SPAN&gt;)]
        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; IList&amp;lt;TEntity&amp;gt; FetchAll()
        {
            &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;return&lt;/SPAN&gt; _ObjectContext.CreateObjectSet&amp;lt;TEntity&amp;gt;().ToList();
        }

        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; IList&amp;lt;TEntity&amp;gt; Fetch(Expression&amp;lt;Func&amp;lt;TEntity, &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;bool&lt;/SPAN&gt;&amp;gt;&amp;gt; where)
        {
            &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;return&lt;/SPAN&gt; _ObjectContext.CreateObjectSet&amp;lt;TEntity&amp;gt;().Where(where).ToList();
        }

        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; TEntity FetchSingle(Expression&amp;lt;Func&amp;lt;TEntity, &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;bool&lt;/SPAN&gt;&amp;gt;&amp;gt; where)
        {
            &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;return&lt;/SPAN&gt; _ObjectContext.CreateObjectSet&amp;lt;TEntity&amp;gt;().SingleOrDefault(where);
        }

        [DataObjectMethod(DataObjectMethodType.Insert, &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;true&lt;/SPAN&gt;)]
        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;int&lt;/SPAN&gt; Create(TEntity entity)
        {
            &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;return&lt;/SPAN&gt; _ObjectContext.CreateObjectSet&amp;lt;TEntity&amp;gt;().AddObject(entity);
        }

        [DataObjectMethod(DataObjectMethodType.Update, &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;true&lt;/SPAN&gt;)]
        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;void&lt;/SPAN&gt; Update(TEntity entity)
        {
            &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;if&lt;/SPAN&gt; (entity.EntityState == EntityState.Detached)
                _ObjectContext.Attach(entity);
        }

        [DataObjectMethod(DataObjectMethodType.Delete, &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;true&lt;/SPAN&gt;)]
        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;void&lt;/SPAN&gt; Delete(TEntity entity)
        {
            _ObjectContext.CreateObjectSet&amp;lt;TEntity&amp;gt;().DeleteObject(entity);
        }

        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;#endregion&lt;/SPAN&gt;
    }

}
}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;"Καμαρώνοντας"&amp;nbsp;τη&amp;nbsp;δημιουργία&amp;nbsp;μου, είπα να τη τρέξω, αλλά&amp;nbsp;η &lt;EM&gt;μόνη&lt;/EM&gt; "πρόχειρη" έκδοση Visual Studio που είχα ήταν το Visual Studio 2008, μιας και βαριώμουν να σηκώσω ένα άλλο VM που είχε Visual Studio 2010. Κάνοντας copy &amp;amp; paste τον κώδικά μου,&amp;nbsp;έφτιαξα και το πρώτο repository entity μου:&lt;/P&gt;
&lt;P&gt;
&lt;TABLE style="BORDER-BOTTOM:#e5e5e5 1px solid;BORDER-LEFT:#e5e5e5 1px solid;BACKGROUND-COLOR:#f2f2f2;BORDER-TOP:#e5e5e5 1px solid;BORDER-RIGHT:#e5e5e5 1px solid;" border=0 cellSpacing=0 cellPadding=0 width="100%"&gt;

&lt;TR style="LINE-HEIGHT:normal;VERTICAL-ALIGN:top;"&gt;
&lt;TD style="TEXT-ALIGN:right;WIDTH:40px;"&gt;&lt;PRE style="PADDING-BOTTOM:2px;MARGIN:0px;PADDING-LEFT:2px;PADDING-RIGHT:2px;FONT-FAMILY:courier new;COLOR:gray;FONT-SIZE:11px;BORDER-RIGHT:#e7e7e7 1px solid;PADDING-TOP:2px;"&gt;1
2
3
4
5
 &lt;/PRE&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;PRE style="PADDING-BOTTOM:2px;MARGIN:0px;PADDING-LEFT:8px;PADDING-RIGHT:2px;PADDING-TOP:2px;"&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:black;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;namespace&lt;/SPAN&gt; RepositoryWebAppv2.Model
{
    &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;class&lt;/SPAN&gt; CustomerRepository : Repository&amp;lt;Customer, NorthwindEntities&amp;gt;
    { }
}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;Και αυτό που πήρα ήταν ένα σφάλμα - δεν χρειάστηκε πολύ να&amp;nbsp;συνειδιτοποιήσω ότι ο κώδικας που είχα γράψει είχε target το EF4 και όχι το EF που έχει το .NET Framework v3.5 SP1. "&lt;EM&gt;Μικρό το κακό&lt;/EM&gt;" σκέφτηκα, και έγραψα μερικές Extension Methods για να το "στρώσω" και για το EF1:&lt;/P&gt;
&lt;P&gt;
&lt;TABLE style="BORDER-BOTTOM:#e5e5e5 1px solid;BORDER-LEFT:#e5e5e5 1px solid;BACKGROUND-COLOR:#f2f2f2;BORDER-TOP:#e5e5e5 1px solid;BORDER-RIGHT:#e5e5e5 1px solid;" border=0 cellSpacing=0 cellPadding=0 width="100%"&gt;

&lt;TR style="LINE-HEIGHT:normal;VERTICAL-ALIGN:top;"&gt;
&lt;TD style="TEXT-ALIGN:right;WIDTH:40px;"&gt;&lt;PRE style="PADDING-BOTTOM:2px;MARGIN:0px;PADDING-LEFT:2px;PADDING-RIGHT:2px;FONT-FAMILY:courier new;COLOR:gray;FONT-SIZE:11px;BORDER-RIGHT:#e7e7e7 1px solid;PADDING-TOP:2px;"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 &lt;/PRE&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;PRE style="PADDING-BOTTOM:2px;MARGIN:0px;PADDING-LEFT:8px;PADDING-RIGHT:2px;PADDING-TOP:2px;"&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:black;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;    &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;static&lt;/SPAN&gt; partial &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;class&lt;/SPAN&gt; Extensions
    {
        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;static&lt;/SPAN&gt; ObjectQuery&amp;lt;T&amp;gt; CreateObjectSet&amp;lt;T&amp;gt;(&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;this&lt;/SPAN&gt; ObjectContext objectcontext)
            where T : EntityObject
        {
            &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;return&lt;/SPAN&gt; objectcontext.GetType().GetProperties().OfType&amp;lt;ObjectQuery&amp;lt;T&amp;gt;&amp;gt;().FirstOrDefault();
        }

        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;static&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;void&lt;/SPAN&gt; DeleteObject&amp;lt;T&amp;gt;(&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;this&lt;/SPAN&gt; ObjectQuery&amp;lt;T&amp;gt; entityset, T entity)
            where T : EntityObject
        {
            entityset.Context.DeleteObject(entity);
        }

        &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;static&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;int&lt;/SPAN&gt; AddObject&amp;lt;T&amp;gt;(&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;this&lt;/SPAN&gt; ObjectQuery&amp;lt;T&amp;gt; entityset, T entity)
            where T : EntityObject
        {
            &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;try&lt;/SPAN&gt;
            {
                entityset.Context.AddObject(entityset.Name, entityset);
            }
            &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;catch&lt;/SPAN&gt; (Exception)
            {
                &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;return&lt;/SPAN&gt; 0;
            }

            &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;return&lt;/SPAN&gt; 1;
        }
    }&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;Και ενώ ήμουν "χαρούμενος" ότι θα έτρεχε, είδα ότι το extension method CreateObjectSet() δεν μου&amp;nbsp;γύριζε ObjectSet&amp;lt;T&amp;gt; που ήθελα, αλλά επέστρεφε πάντα null.&lt;/P&gt;
&lt;P&gt;Κάποια ιδέα γιατί το εν λόγω method δεν συμπεριφέρεται όπως περίμενα; "Φώτα" κάποιος;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;George J.&lt;BR&gt;&lt;/P&gt;</description></item></channel></rss>