An error occurred while receiving the HTTP response to http://localhost:8732/Design_Time_Addresses/WcfServiceLibraryTest/GenreService/.
This could be due to the service endpoint binding not using the HTTP protocol.
This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down).
See server logs for more details.
There was an error while trying to serialize parameter http://tempuri.org/:ListGenresResult.
The InnerException message was 'Object graph for type 'System.Data.Linq.EntitySet`1[[DataLayer.Musician, DataLayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' contains cycles and cannot be serialized if reference tracking is disabled.'.
Solution:
Serialization Mode : Unidirectional (dbml file)
WCF Logging:
http://msdn.microsoft.com/en-us/library/ms732009.aspx
http://msdn.microsoft.com/en-us/library/ms730064.aspx
Wcf Linq Serialization Error
Etiketler: linq to sql , wcf
Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() operator
code:
var cpList2 = (from customerProduct in _context.customer_products
join controlPolice in controlPolices
on customerProduct.sales_ID equals controlPolice.sales_ID
where customerProduct.yenileme_no == controlPolice.yenileme_no
&& customerProduct.zeyil_no == controlPolice.zeyil_no
select customerProduct);
error:
Local sequence cannot be used in LINQ to SQL implementation of query
operators except the Contains() operator
solution:
var cpList = (from controlPolicy in controlPolicies
join customerProduct in _context.customer_products
on controlPolicy.sales_ID equals customerProduct.sales_ID
where controlPolicy.yenileme_no == customerProduct.yenileme_no
&& controlPolicy.zeyil_no == customerProduct.zeyil_no
select customerProduct);
source:
http://stackoverflow.com/questions/5936301/local-sequence-cannot-be-used-in-linq-to-sql-implementations-of-query-operators-e
Etiketler: linq , linq to sql
ForeignKeyReferenceAlreadyHasValueException
Çözüm:
cover.OriginalSongId = song.SongId;
yerine,
cover.OriginalSong = song;
http://dotnetslackers.com/Community/blogs/bmains/archive/2009/05/21/linq-to-sql-error-foreignkeyreferencealreadyhasvalueexception.aspx
http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/744b2c6a-ecb8-44bf-b72a-dc1b85b34342
If the association property is assigned a value you cannot change the foreign key field anymore, you must change the relationship by changing the assocition property. For example, using Customer and Order from Northwind sample database. If the 'Customer' property on an order is assigned a value you can no longer manually change the order's CustomerID field, since it must match the PK of the customer. You can, however, change the 'Customer' property directly, assigning it a new customer instance. This action will automatically update the CustomerID field to match.
Etiketler: exception , ForeignKeyReferenceAlreadyHasValueException , linq to sql
linq to sql - [error] row not found or changed
I solved this error by redragging over a table from the server explorer to the designer and re-building. So indeed, the designer was out-of-synch with the actual SQL Table.
http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/thread/c672c8ee-bf2a-41b4-bb8b-aa76cc5d9b95/
Etiketler: linq to sql
linq to sql - başka tablolardaki ilişkili kayıtları silmek
bir tablodan bir kayıt silinecekken bu kayıtla ilişkili diğer tablolardaki tüm kayıtlar da otomatik olarak silinmek isteniyorsa...
örnek:
prod tablosundan bir kayıt silinecek ve bunla ilgili olarak prod_lang ve prod_usagaearea tablolarındaki ilişkili kayıtlar da silinecek ise;
prod & prod_lang ve prod & prod_usagearea tabloları arasındaki ilişkiler (associations) 'de delete rule özelliği cascade olarak ayarlanmalı.
Etiketler: cascade , delete rule , linq to sql
linq to sql - left outer join with
var prod_Langs = from p_l in db.Prod_Langs
join p in db.Prods on p_l.ProdID equals p.ProdID
join p_ua in db.Prod_UsageAreas on p_l.ProdID equals p_ua.ProdID
where (catId == null || catId < 1 || p.CatID == catId)
&& (brandId == null || brandId < 1 || p.BrandID == brandId)
&& (usageAreaId == null || usageAreaId < 1 || p_ua.UsageAreaID == usageAreaId)
&& p_l.LangID == langId
select p_l;
yerine
var prod_Langs = from p_l in db.Prod_Langs
join p in db.Prods on p_l.ProdID equals p.ProdID
join p_ua in db.Prod_UsageAreas on p.ProdID equals p_ua.ProdID
into data from x in data.DefaultIfEmpty()
where (catId == null || catId < 1 || p.CatID == catId)
&& (brandId == null || brandId < 1 || p.BrandID == brandId)
&& (usageAreaId == null || usageAreaId < 1 || x.UsageAreaID == usageAreaId)
&& p_l.LangID == langId
select p_l;
linq join'i inner join olarak sql'e çeviriyor. left outer join için
into data from x in data.DefaultIfEmpty()
kısmını ekledik.
http://www.oguzyagmur.com/PermaLink,guid,b9fcc750-0e3b-43e4-a9e8-212ee94afa4e.aspx
Etiketler: left outer join , linq to sql
linq to sql - [error] An attempt was made to remove a relationship between a [mastertable] and a [detailtable]. However, one of the relationship's foreign keys (detailtable.foreignkey1) cannot be set to null
<Table Name="dbo.OrderDetail" Member="OrderDetails"> <Type Name="OrderDetail"> <Column Name="OrderDetailID" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> <Column Name="OrderID" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> <Column Name="ProductID" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> <Column Name="Quantity" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> <Column Name="Price" Type="System.Decimal" DbType="Money" CanBeNull="true" /> <Column Name="Modified" Type="System.Data.Linq.Binary" DbType="rowversion NOT NULL" CanBeNull="false" IsVersion="true" /> <Association Name="Order_OrderDetail" Member="Order" ThisKey="OrderID" Type="Order" IsForeignKey="true"/>Name="Product_OrderDetail" Member="Product" ThisKey="ProductID" Type="Product" IsForeignKey="true" /> Type>
<Association Name="Order_OrderDetail" Member="Order" ThisKey="OrderID" Type="Order" IsForeignKey="true" DeleteOnNull="true"/>
http://blogs.msdn.com/bethmassi/archive/2008/02/19/one-to-many-master-detail-forms-with-linq-to-sql.aspx
not: 1. yol sorunu çözdü.
not 2. eğer ilişki prod, usagearea, prod_usagearea biçimindeyse;
[Association(Name="Prod_Prod_UsageArea", Storage="_Prod", ThisKey="ProdID", OtherKey="ProdID", IsForeignKey=true, DeleteOnNull = true)]
[Association(Name = "UsageArea_Prod_UsageArea", Storage = "_UsageArea", ThisKey = "UsageAreaID", OtherKey = "UsageAreaID", IsForeignKey = true, DeleteOnNull = true)]
prod_usagearea tablosu:
prodid (primarykey, int, not null)
usageareaid (primarykey, int, not null)
Etiketler: linq to sql , one to many
linq to sql - Type 'http://microsoft.com/wsdl/types/:char' is not declared
web service char alan içeren bir objeyi döndüremiyor.
char alanı varchar'a çevirdiğim halde, dbml'de değişmiyor. elle değiştirmek gerekiyor.
aynı şekilde wsdl'de de elle değişiklikler gerekebilir.
Etiketler: linq to sql , web service
web service - linq to sql & web service
public class IntertechWS : System.Web.Services.WebService
{
[WebMethod]
public SerializableEntity<Page> GetPage(int id)
{
PageController ctrl = new PageController();
Page page = ctrl.GetPage(id);
SerializableEntity<Page> entity = new SerializableEntity<Page>(page);
return entity;
//IntertechDBDataContext db = new IntertechDBDataContext();
//var page = db.Pages.SingleOrDefault<Page, SerializableEntity<Page>>(p => p.PageID == id);
//return page;
}
[WebMethod]
public List<SerializableEntity<Page>> GetSubPages(int id, int langId)
{
PageController ctrl = new PageController();
return ctrl.GetSubPages(id, langId).ToList<Page, SerializableEntity<Page>>();
//IntertechDBDataContext db = new IntertechDBDataContext();
//var pages = db.Pages.ToList<Page, SerializableEntity<Page>>();
//return pages;
}
}
Etiketler: linq to sql , web service
linq to sql - Make Entities Serializable (LINQ to SQL)
Etiketler: linq to sql , serialization
System.InvalidOperationException: A circular reference was detected while serializing an object of type
One of the important that things that you will likely have to do at one point or another with entity objects is serialize them. This could be for Web Services most commonly but could be for any sort of storage or transport scenario.
There are a number of pitfalls with this scenario however, primarily because LINQ to SQL will very likely generate circular references into your entity model from your data and XML Serialization will fail outright in that scenario. For example, say you have a customer and projects table and if you let LINQ generate the one to many relationship it will create Customer entity with a Projects property and a Project entity with a Customer property.
For code scenarios this is probably a good thing - you want to be able to see all Projects and filter that list in your code.
Unfortunately in a serialization scenario this doesn't work because you essentially have a circular reference - Customer ->Projects -> Customer. So we have a 1 -> Many and a 1 - 1 relationship going back to the original object here.
Etiketler: linq to sql , serialization