• Webseitenerstellung und -hosting
  • .NET Anwendungsentwicklung
  • softwaregesteuerte Prozessoptimierung
  • .NET

    Programmierung

  • WebseitenErstellung

    undHosting

  • softwaregesteuerte

    Prozessoptimierung

  • Konzeption

    und Beratung

%AM, %05. %504 %2013 %11:%Jul

Entitäten klonen und vergleichen mit dem Entity Framework 4

geschrieben von
Artikel bewerten
(0 Stimmen)
Da solche Funktionen erst mit EF5 bzw. .NET 4.5 halbwegs vernünftig zur Verfügung stehen ("AsNoTracking") hier eine Möglichkeit um Entitäten zu klonen (als Extension :-))

;
Public Function Clone(Of t As EntityObject)(entity As t, ctx As oraEntities, Optional copyKeys As Boolean = True) As t
Try
Dim cloneE As t = ctx.CreateObject(Of t)()
Dim pis As PropertyInfo() = entity.GetType.GetProperties()

For Each pi As PropertyInfo In pis
Dim attrs As EdmScalarPropertyAttribute() = DirectCast(pi.GetCustomAttributes(GetType(EdmScalarPropertyAttribute), False), EdmScalarPropertyAttribute())

For Each attr As EdmScalarPropertyAttribute In attrs
If Not copyKeys AndAlso attr.EntityKeyProperty Then
Continue For
End If
'Strung und NULL abfangen, wird trotz Standardwert im SQL Server nicht imgesetzt
Dim objVal As Object
If pi.PropertyType = GetType(String) And pi.GetValue(entity, Nothing) Is Nothing Then
objVal = ""
Else
objVal = pi.GetValue(entity, Nothing)
End If
pi.SetValue(cloneE, objVal, Nothing)
Next
Next
Return cloneE
Catch ex As Exception
Throw ex
End Try
End Function


und zu vergleichen


;
Public Function Compare(Of t As EntityObject)(entityOriginal As t, entityCopy As t) As Boolean
Try
'Um Änderungen einer Entität festzustellen (t.equals funktioniert aufgrund der Abhängigkeiten mit anderen Tabellen nicht)
Dim pisOrig As PropertyInfo() = entityOriginal.GetType.GetProperties()

For Each piOrig As PropertyInfo In pisOrig
Dim attrs As EdmScalarPropertyAttribute() = DirectCast(piOrig.GetCustomAttributes(GetType(EdmScalarPropertyAttribute), False), EdmScalarPropertyAttribute())
If attrs.Count > 0 Then 'Fremdschlüsseltabellen ausschliessen
Dim objOrig As Object = If(GetType(t).GetProperty(piOrig.Name).GetValue(entityOriginal, Nothing) Is Nothing, "", GetType(t).GetProperty(piOrig.Name).GetValue(entityOriginal, Nothing))
Dim objCopy As Object = If(GetType(t).GetProperty(piOrig.Name).GetValue(entityCopy, Nothing) Is Nothing, "", GetType(t).GetProperty(piOrig.Name).GetValue(entityCopy, Nothing))
If Not objOrig.Equals(objCopy) Then
Return False
End If
End If
Next

Return True
Catch ex As Exception
Throw ex
End Try
End Function


Verknüfte Tabellen werden dabei allerdings nicht übernommen!		
Gelesen 44526 mal Letzte Änderung am %PM, %24. %643 %2015 %14:%Jun

381 Kommentare

  • Kommentar-Link Shanehurdy %AM, %25. %139 %2024 %02:%Jun gepostet von Shanehurdy

    Thank you for every other informative web site. The place else could I am getting that kind of information written in such a perfect means? I've a challenge that I'm just now working on, and I have been on the look out for such info.

    myworldavto.ru/page/8 
    freedomsolargenerators.com/index.php?do=/public/user/blogs/name_Alanpoe/page_7/ 
    batdongsanmiennam.vn/mnre-tich-cuc-day-manh-kenh-ban-hang-truc-tuyen/ 
    http://www.afchornchurch.com/2005/reports/16.shtml 
    mutinyhockey.com/memberlist.php?mode=joined&order=ASC&start=336850%C3%82%C2%A0 

  • Kommentar-Link FobertUnife %AM, %25. %042 %2024 %00:%Jun gepostet von FobertUnife

    This is really interesting, You are a very skilled blogger. I have joined your feed and look forward to seeking more of your wonderful post. Also, I've shared your website in my social networks!

    tietkiemxanghoangson.com.vn/en/ 
    http://www.rusforum.com/group.php?do=discuss&group=&discussionid=662 
    ahfc.org/beach-soccer/switzerland/ 
    tnrevergreen.com.vn/dien-tich-tim-tuong-la-gi-mua-nha-nen-dung-cach-tinh-dien-tich-nao/ 
    beta.getonvibe.net/blogs/246/Why-is-the-popularity-of-universities-constantly-declining-nowadays 

  • Kommentar-Link FobertUnife %PM, %24. %999 %2024 %22:%Jun gepostet von FobertUnife

    Pretty section of content. I just stumbled upon your website and in accession capital to assert that I get actually enjoyed account your blog posts. Anyway I'll be subscribing to your feeds and even I achievement you access consistently rapidly.
    http://pro-korolev.ru/nyukasl-planiruet-usilitsya-gibbsom.html

    купить аттестат за 9 класс
    http://icefoutreach.ru

    купить диплом в подольске

  • Kommentar-Link Earnestcix %PM, %24. %990 %2024 %22:%Jun gepostet von Earnestcix

    Right now it seems like BlogEngine is the best blogging platform available right now. (from what I've read) Is that what you are using on your blog?

    vadaszapro.eu/user/profile/1266221 
    hellados.ru/texts/io.php 
    forum.analysisclub.ru/index.php/topic,171620.0.html?PHPSESSID=be9d29ff90e59b2f12dbf03eb3ada3ec 
    vxengine.ru/blogs/258/%D0%A1%D0%BA%D0%BE%D0%BB%D1%8C%D0%BA%D0%BE-%D0%BE%D1%80%D0%B8%D0%B5%D0%BD%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%BE%D1%87%D0%BD%D0%BE-%D1%81%D0%B5%D0%B3%D0%BE%D0%B4%D0%BD%D1%8F-%D0%B1%D1%83%D0%B4%D0%B5%D1%82-%D1%81%D1%82%D0%BE%D0%B8%D1%82%D1%8C-%D0%BA%D0%B0%D1%87%D0%B5%D1%81%D1%82%D0%B2%D0%B5%D0%BD%D0%BD%D1%8B%D0%B9-%D0%B4%D0%B8%D0%BF%D0%BB%D0%BE%D0%BC 
    avtovideotest.ru/kupit-diplom-s-besplatnoy-dostavkoy-po-vsey-rossii 

  • Kommentar-Link Lhanehurdy %PM, %24. %897 %2024 %20:%Jun gepostet von Lhanehurdy

    Hi there, You have done a great job. I'll certainly digg it and personally recommend to my friends. I'm confident they'll be benefited from this site.

    http://www.suicide-forum.com/member.php?12290-sonnick84&tab=visitor_messaging&page=1 
    containersales.ru/type/2/ 
    jboi2007.org/Galeries/Day1/BeachVolleyball/photo5.htm 
    blouson-moto.net/Blousons/ixon.html 
    http://www.4yo.us/blogs/109456/%D0%98%D0%B7%D0%B1%D0%B0%D0%B2%D1%8C%D1%82%D0%B5%D1%81%D1%8C-%D0%BE%D1%82-%D1%81%D0%BB%D0%BE%D0%B6%D0%BD%D0%BE%D1%81%D1%82%D0%B5%D0%B9-%D1%81-%D1%83%D1%87%D0%B5%D0%B1%D0%BE%D0%B9-%D0%BA%D1%83%D0%BF%D0%B8%D1%82%D0%B5-%D0%B4%D0%B8%D0%BF%D0%BB%D0%BE%D0%BC 

  • Kommentar-Link StephenNef %AM, %24. %433 %2024 %09:%Jun gepostet von StephenNef

    Hello everyone, it's my first pay a visit at this site, and paragraph is truly fruitful designed for me, keep up posting these content.

    prmaster.su/personal_blog/good/page82/ 
    effective-herbal-cure.com/hoodia-gordonii-extract/fast-fat-reduction.htm 
    myworldoftank.ru/article/kak-vklyuchit-otobrazhenie-shansov-na-pobedu-xvm-v-world-of-tanks.html 
    officesetupc.com/blog/get-the-latest-features-in-office/ 
    http://www.aikidosydney.com/cdn-cgi/l/email-protection 

  • Kommentar-Link OLanehurdy %AM, %24. %335 %2024 %07:%Jun gepostet von OLanehurdy

    Hey! Do you use Twitter? I'd like to follow you if that would be okay. I'm absolutely enjoying your blog and look forward to new posts.

    onlinekinofun.ru/kupit-diplom-s-besplatnoy-dostavkoy-po-vsey-rossii 
    gadjetforyou.ru/kupit-diplom-10 
    girlscools.ru/page/39 
    sport-faq.ru/page/4 
    inspiretemplate.com/opencart/freeze/index.php?route=information/blogger&blogger_id=4 

  • Kommentar-Link Lewisbib %AM, %24. %283 %2024 %05:%Jun gepostet von Lewisbib

    The other day, while I was at work, my sister stole my iPad and tested to see if it can survive a 30 foot drop, just so she can be a youtube sensation. My apple ipad is now broken and she has 83 views. I know this is totally off topic but I had to share it with someone!

    http://www.sabalsuppliers.com.np/product/view/6-zone-fire-alarm-panel 
    http://www.sshcongregation.org/fullnews?sn=76 
    forum.zub-zub.ru/viewtopic.php?t=25938 
    http://www.redlideres.cl/lider/sergio-rica/ 
    fastpas.info/ 

  • Kommentar-Link IsmaelLit %AM, %24. %193 %2024 %03:%Jun gepostet von IsmaelLit

    Excellent, what a blog it is! This web site gives helpful information to us, keep it up.

    we-are-family.ru/contact.htm 
    grp.7olimp.ru/viewtopic.php?f=13&t=1895&p=2457 
    programasites.com.br/blog/post/11666/e-mail-marketing-boas-praticas-e-temas-para-abordar 
    1abakan.ru/forum/showthread-76051/ 
    stephenireland.com/charity/details.php?10-000-RAISED-FOR-FRANCIS-HOUSE-CHILDREN-S-HOSPICE-3 

  • Kommentar-Link DichaelANYMN %PM, %23. %638 %2024 %14:%Jun gepostet von DichaelANYMN

    Thanks for any other informative website. Where else could I am getting that kind of information written in such an ideal method? I have a venture that I am simply now working on, and I have been at the glance out for such information.

    zelao41.ru/a-korolev-vzorvus-a-zhivym-ne-damsya/ 
    mangopik.com/sximodemo7/posts/read/printing-and-typesetting-industry 
    http://www.youthconnect.lightformany.org/blogs/1581/Where-to-buy-a-diploma-or-certificate-at-a-bargain 
    http://www.windmaster.cl/old/web/posts/272/windsurf-tenerife-big.html 
    formfinance.ru/kupit-diplom-lyubogo-obraztsa 

Schreibe einen Kommentar

Bitte achten Sie darauf, alle Felder mit Stern * zu füllen. HTML-Code ist nicht erlaubt.